enum_to_string

Crates.ioenum_to_string
lib.rsenum_to_string
version0.1.0
sourcesrc
created_at2023-10-11 23:09:03.420603
updated_at2023-10-11 23:09:03.420603
descriptionGenerate a serialized string using the display trait easily
homepagehttps://github.com/benfaerber/enum_to_string
repositoryhttps://github.com/benfaerber/enum_to_string
max_upload_size
id1000763
size2,760
Ben Faerber (benfaerber)

documentation

README

enum_all_variants

Proc macro for generating impl Display for enums using serde_json

Example

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
Commit count: 2

cargo fmt