Derive Macro surjective_enum::From
source · #[derive(From)]
Expand description
Derive a surjective ::core::convert::From
The example
use surjective_enum::From;
#[repr(u8)]
#[derive(From)]
pub enum Enum {
Bar = 0b00,
Foo = 0b01,
Rest = 0b11
}
will create a from(u8) -> Enum conversion function which maps 0 -> Bar, 1 -> Foo and all other values to Rest.