light_enum
A crate providing a derive keyword to generate a light enum.
Usage
cargo add light_enum
This crate provide two derive keywords:
LightEnum
will generate a new enum without the content of each fieldValues
will generate a vector containing each field of the enum
See examples bellow to understand what they do.
LightEnum
use LightEnum;
let heavy = A;
let light = heavy.to_light;
assert!;
MyEnumLight
will be generated:
Values
use Values;
let values = VALUES;
assert!;
assert!;
assert!;
assert!;
Generated code:
Limitations
Values
Having a field with content will cause an error.
// this code will not compile
Dev
The cargo expand
utility is useful to see what is generated. It can be installed with cargo install cargo-expand
.