A set of procedural macros for deriving useful functionality on enums.
See [the API docs] for more information.
FromStr
]An efficient, configurable FromStr
implementation for C-like enums.
```rust
enum Test { Alpha, Beta, }
asserteq!("Alpha".parse(), Ok(Test::Alpha)); asserteq!("Beta".parse(), Ok(Test::Beta)); ```
IterVariants
]A static method returning an iterator over the variants of an enum.
```rust
pub enum Direction { North = 1, East, South, West, }
use Direction::*;
assert_eq!(Direction::iter().collect::
TryFromRepr
] and [ReprFrom
]Conversion to and from the discriminant of a C-like enum.
```rust use std::convert::TryInto;
pub enum Direction { North = 1, East, South, West }
use Direction::*; asserteq!(1u8, North.into()); asserteq!(4u8, West.into()); asserteq!(North, 1u8.tryinto().unwrap()); asserteq!(West, 4u8.tryinto().unwrap()); ```