Skip to content

Support an override? #7

@mqudsi

Description

@mqudsi

Hey, thanks for this crate. I was looking into a lighter alternative to strum and came across it, but I think it's missing one important feature that comes in quite handy (or else I didn't see how to do it in the docs).

It's common to have an enum that can have its Display automatically derived easily:

#[derive(EnumDisplay)]
enum Foo {
    Fox,
    Hen,
}

but then later on to end up with a member that doesn't lend itself to a direct one-to-one mapping between its textual representation and the desired Display output:

#[derive(EnumDisplay)]
enum Foo {
    Fox,
    Hen,
    FoxHound,
}

in which case it would be great if you could just annotate the item in question:

#[derive(EnumDisplay)]
enum Foo {
    Fox,
    Hen,
    #[display("Fox Hound")]
    FoxHound,
}

instead of having to drop EnumDisplay and implement Display yourself.

Is this something you'd consider adding to the crate?

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions