Skip to content

Generate a serialized string using the display trait easily

Notifications You must be signed in to change notification settings

benfaerber/enum_to_string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Generate a serialized string using the display trait easily

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages