#[derive(Name)]
{
// Attributes available to this derive:
#[name]
}
Expand description
Generate a method name(&self) -> &'static str that
returns the name of a given enum variant.
If the name-trait feature is enabled, an implementation
of a Name trait is generated. Otherwise, an inherent
implementation is used.
The name of an enum variant is its identifier in Title Case.
Foo becomes "Foo" and HelloWorld becomes "Hello World.
This can be overridden by using the #[name = "..."] attribute
on a variant, e.g.:
use enum_fun::Name;
#[derive(Name)]
enum Words {
Foo,
#[name = "Baz"]
Bar,
}
assert_eq!(Words::Foo.name(), "Foo");
assert_eq!(Words::Bar.name(), "Baz");