1 unstable release
0.1.0 | Nov 19, 2022 |
---|
#26 in #utility-macro
Used in pino_utils
5KB
72 lines
Example usage
use pino_enum_string::enum_string;
#[enum_string]
enum Weapon {
Red,
Blue,
Green,
}
fn main() {
assert_eq!("Red", Weapon::Red.to_string());
assert_eq!("Blue", Weapon::Blue.to_string());
assert_eq!("Green", Weapon::Green.to_string());
}
lib.rs
:
Derive macro to implement display for each variant of enum
use pino_enum_string::enum_string;
#[enum_string]
enum Weapon {
Red,
Blue,
Green,
}
fn main() {
assert_eq!("Red", Weapon::Red.to_string());
assert_eq!("Blue", Weapon::Blue.to_string());
assert_eq!("Green", Weapon::Green.to_string());
}
Dependencies
~1.5MB
~37K SLoC