vendredi 1 février 2019

Is it possible to get the name of a struct using one of its methods?

For example:

struct ABC {
    ...
}

impl ABC {
    fn some_method(&self) -> &str {
        // return the name of its struct -> "ABC"
    }
}

In Python, I can get this using self.__class__.__name__. Is there anything similar in Rust?





Aucun commentaire:

Enregistrer un commentaire