Skip to content

Macro for implementing std::fmt::Display on enum variants. Over 500K crates.io downloads!

License

Notifications You must be signed in to change notification settings

SeedyROM/enum-display

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enum-display

GitHub crates.io version docs.rs docs crates.io version CI build

enum-display is a crate for implementing std::fmt::Display on enum variants with macros.

Simple Example

use enum_display::EnumDisplay;

#[derive(EnumDisplay)]
enum Color {
  Red,
  Green,
  Blue,
}

assert_eq!(Color::Red.to_string(), "Red");
assert_eq!(Color::Green.to_string(), "Green");
assert_eq!(Color::Blue.to_string(), "Blue");

Example With Custom Case Transform

Any case from convert_case is supported.

use enum_display::EnumDisplay;

#[derive(EnumDisplay)]
#[enum_display(case = "Kebab")]
enum Message {
    HelloGreeting { name: String },
}

assert_eq!(Message::HelloGreeting { name: "Alice".to_string() }.to_string(), "hello-greeting");

About

Macro for implementing std::fmt::Display on enum variants. Over 500K crates.io downloads!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages