Crates.io | alt-enum |
lib.rs | alt-enum |
version | 0.1.4 |
source | src |
created_at | 2022-08-26 16:59:31.789479 |
updated_at | 2022-09-02 17:49:09.402485 |
description | Various macros providing a more beautiful syntax for enums |
homepage | |
repository | https://github.com/miralushch/alt-enum |
max_upload_size | |
id | 652895 |
size | 6,040 |
Various macros providing more beautiful syntax for enums.
Macro providing a more beautiful syntax for enums.
use alt_enum::alt_enum;
alt_enum!(
#[derive(Debug)]
test enum:
first,
second-variant,
nyan nyan
);
assert_eq!(format!("{:?}", TestEnum::SecondVariant), "SecondVariant");
Macro providing a more beautiful syntax for enums with associated values.
(using value-enum crate, needs value_enum feature enabled)
use alt_enum::alt_val_enum;
alt_val_enum!(
#[derive(Debug)]
some nya -> &'static str:
first: "42",
second-variant: "meow",
nyan nyan: "nyaa~"
);
assert_eq!(<&str>::from(SomeNya::NyanNyan), "nyaa~");