2 releases
| 0.1.1 | May 25, 2025 |
|---|---|
| 0.1.0 | Apr 6, 2025 |
#4 in #proc-derive
128 downloads per month
Used in 8 crates
(via macron)
11KB
134 lines
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