Skip to content

Enum tag support #6

Description

@sucaba

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));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions