Crates.io | value-enum |
lib.rs | value-enum |
version | 1.0.0 |
source | src |
created_at | 2022-08-26 09:16:06.316622 |
updated_at | 2023-07-31 18:45:10.423612 |
description | Macro for generating enums associated with values |
homepage | |
repository | https://github.com/mira-neko/value-enum |
max_upload_size | |
id | 652671 |
size | 6,226 |
Macro for generating enums associated with values.
use value_enum::value_enum;
value_enum!(
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
enum Abc: char {
A = 'a',
B = 'b',
C = 'c',
}
);
assert_eq!(
char::from(Abc::A),
'a'
);
assert_eq!(
Abc::try_from('b'),
Ok(Abc::B)
);