macro_rules! of_var {
($ident:ident) => { ... };
}Expand description
Get the name of the given local variable or constant as a string literal.
This macro checks that the identifier is valid in the current scope. If the identifier is renamed via refactoring tools, the macro call will be updated accordingly.
ยงExamples
let my_variable = 42;
const MY_CONSTANT: u32 = 42;
assert_eq!(pretty_name::of_var!(my_variable), "my_variable");
assert_eq!(pretty_name::of_var!(MY_CONSTANT), "MY_CONSTANT");