Derive Macro num_enum_derive::IntoPrimitive[][src]

#[derive(IntoPrimitive)]

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,
}

fn main() {
    let zero: u8 = Number::Zero.into();
    assert_eq!(zero, 0u8);
}