#[derive(Cast)]
{
// Attributes available to this derive:
#[string]
}
Expand description
Implements Reflect
, FromValue
, and IntoValue
for an enum.
The enum will become castable from kebab-case strings. The doc-comments will
become user-facing documentation for each variant. The #[string]
attribute
can be used to override the string corresponding to a variant.
ⓘ
/// A stringy enum of options.
#[derive(Cast)]
enum Niceness {
/// Clearly nice (parses from `"nice"`).
Nice,
/// Not so nice (parses from `"not-nice"`).
NotNice,
/// Very much not nice (parses from `"❌"`).
#[string("❌")]
Unnice,
}