Crate macron_impl_display

Source
Expand description

githubcrates-iodocs-rs

§Impl Display Macro

§Introduction:

The implementation of trait Display.

P.s.: More useful macros you can find here.

§Examples:

#[derive(Display)]
#[display = "Hello, {name}!"]
struct Hello {
    pub name: &'static str,
}

let hello = Hello { name: "World" };

assert_eq!(format!("{hello}"), "Hello, World!");
#[derive(Display)]
enum Animals {
    #[display = "it's a dog"]
    Dog,
    
    #[display = "cat '{0}'"]
    Cat(&'static str, u8),

    #[display = "bird '{name}'"]
    Bird { name: &'static str, age: u8 },
}

let dog = Animals::Dog;
assert_eq!(format!("{dog}"), "it's a dog");

let cat = Animals::Cat("Tomas", 1);
assert_eq!(format!("{cat}"), "cat 'Tomas'");

let bird = Animals::Bird { name: "Kesha", age: 1 };
assert_eq!(format!("{bird}"), "bird 'Kesha'");

§Licensing:

Distributed under the MIT license.

§Feedback:

You can contact me via GitHub or send a message to my Telegram @fuderis.

This library is constantly evolving, and I welcome your suggestions and feedback. See the documentation here macron documentation

Derive Macros§

Display
The implementation of trait Display