5 releases
0.1.4 | Dec 27, 2024 |
---|---|
0.1.3 | Dec 15, 2024 |
0.1.2 | Dec 15, 2024 |
0.1.1 | Dec 12, 2024 |
0.1.0 | Dec 12, 2024 |
#930 in Rust patterns
186 downloads per month
7KB
105 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
~230–700KB
~17K SLoC