#[derive(ReprFrom)]
{
// Attributes available to this derive:
#[enumeration]
}
Expand description
Derives From<CLikeEnum>
for the primitive representation specified in #[repr(...)]
.
§Examples
#[derive(Debug, Clone, Copy, PartialEq, Eq, enum_utils::ReprFrom)]
#[repr(u8)]
pub enum Direction {
North = 1,
East,
South,
West
}
use Direction::*;
assert_eq!(1u8, North.into());
assert_eq!(4u8, West.into());
This macro only works on C-like enums.
ⓘ
#[derive(Debug, Clone, enum_utils::TryFromRepr)]
#[repr(u8)]
pub enum Letter {
A,
B,
Other(u8),
}