[−][src]Derive Macro enum_utils::TryFromRepr
#[derive(TryFromRepr)]
{
// Attributes available to this derive:
#[enumeration]
}Derives TryFrom<Repr> for an enum, where Repr is a primitive representation specified
in #[repr(...)].
Examples
use std::convert::TryInto; #[derive(Debug, Clone, Copy, PartialEq, Eq, enum_utils::TryFromRepr)] #[repr(u8)] pub enum Direction { North = 1, East, South, West } use Direction::*; assert_eq!(North, 1u8.try_into().unwrap()); assert_eq!(West, 4u8.try_into().unwrap());