Hi,
I'm trying to implement Debug or Format for enums (yes, I know about the derive) and
don't want to hardcode enum tag names as strings.
Potentially, enum tags can change names in future and I want to be sure that print-ed values will follow names.
Was thinking about using nameof for this. For instance:
enum Color {
Red(i32),
Green(i32),
Blue(i32),
}
name_of!(enum Color::Green(42));
// or
tag_of!(Color::Green(42));
Hi,
I'm trying to implement Debug or Format for enums (yes, I know about the derive) and
don't want to hardcode enum tag names as strings.
Potentially, enum tags can change names in future and I want to be sure that print-ed values will follow names.
Was thinking about using
nameoffor this. For instance: