[−][src]Attribute Macro int_enum::int_enum
#[int_enum]
Attribute macro taking the integer type for the enum.
Example
use int_enum::*; #[int_enum(u8)] #[derive(Debug, PartialEq)] pub enum SmallInt { One = 1, Two = 2, } fn main() { assert_eq!(SmallInt::One.as_int(), Some(1)); assert_eq!(SmallInt::from_int(2), Some(SmallInt::Two)); assert_eq!(SmallInt::from_int(5), None); }