Derive Macro num_enum::IntoPrimitive
#[derive(IntoPrimitive)]
{
// Attributes available to this derive:
#[num_enum]
#[catch_all]
}
Expand description
Implements Into<Primitive>
for a #[repr(Primitive)] enum
.
(It actually implements From<Enum> for Primitive
)
ยงAllows turning an enum into a primitive.
use num_enum::IntoPrimitive;
#[derive(IntoPrimitive)]
#[repr(u8)]
enum Number {
Zero,
One,
}
let zero: u8 = Number::Zero.into();
assert_eq!(zero, 0u8);