Crates.io | enum_to_string |
lib.rs | enum_to_string |
version | 0.1.0 |
source | src |
created_at | 2023-10-11 23:09:03.420603 |
updated_at | 2023-10-11 23:09:03.420603 |
description | Generate a serialized string using the display trait easily |
homepage | https://github.com/benfaerber/enum_to_string |
repository | https://github.com/benfaerber/enum_to_string |
max_upload_size | |
id | 1000763 |
size | 2,760 |
Proc macro for generating impl Display for enums using serde_json
use enum_to_string::ToJsonString;
use serde::Serialize;
#[derive(Debug, Serialize, ToJsonString)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
enum Direction {
Left,
Top,
Right,
Bottom,
}
fn main() {
println!("{}", Direction::Left.to_string());
}
Outputs:
LEFT