Struct std::typing::EnumVariant
Enum variant descriptor.
This struct provides compile-time reflection information about a variant of an enum.
It is created by calling variants on an enum type.
Example
use std::typing::Type;
enum Foo {
Bar,
Quux,
}
let desc: Type<Foo> = Type::new();
let variants = desc.variants();
assert_eq!(variants[0].name(), "Bar");
assert_eq!(variants[0].value(), Foo::Bar);
assert_eq!(variants[1].name(), "Quux");
assert_eq!(variants[1].value(), Foo::Quux);
Run this example
Methods
impl EnumVariant<T> { ... }
-
fn name(self: &EnumVariant<T>) -> &[u8]
Returns the name of the enum variant.
-
fn value(self: &EnumVariant<T>) -> T
Returns the value of the enum variant.