4 releases
new 0.1.3 | Dec 15, 2024 |
---|---|
0.1.2 | Dec 15, 2024 |
0.1.1 | Dec 12, 2024 |
0.1.0 | Dec 12, 2024 |
#932 in Rust patterns
394 downloads per month
6KB
98 lines
enum-unit
Description
Generates unit-variant enums from existing enums.
Example
use enum_unit::*;
#[derive(EnumUnit)]
enum Example {
A(i16),
B { id: u8 },
}
fn main() {
let a = Example::A(-420);
assert_eq!(ExampleUnit::A, a.into());
let b = Example::B { id: 69 };
assert_eq!(ExampleUnit::B, b.into());
}
Features
Enable the bitflag
feature to use the enum-units as bitflags as well.
Dependencies
~225–690KB
~16K SLoC