#proc-macro #macro-derive #proc-derive

macro macron-impl-display

The implementation of trait Display

2 releases

0.1.1 May 25, 2025
0.1.0 Apr 6, 2025

#4 in #proc-derive

Download history 30/week @ 2025-09-18 41/week @ 2025-09-25 23/week @ 2025-10-02 17/week @ 2025-10-09 49/week @ 2025-10-16 30/week @ 2025-10-23 15/week @ 2025-10-30 18/week @ 2025-11-06 26/week @ 2025-11-13 21/week @ 2025-11-20 29/week @ 2025-11-27 25/week @ 2025-12-04 20/week @ 2025-12-11 33/week @ 2025-12-18 23/week @ 2025-12-25 46/week @ 2026-01-01

128 downloads per month
Used in 8 crates (via macron)

MIT license

11KB
134 lines

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.

Dependencies

~140–530KB
~13K SLoC