| Crates.io | macron-impl-display |
| lib.rs | macron-impl-display |
| version | 0.1.1 |
| created_at | 2025-04-06 14:57:44.669943+00 |
| updated_at | 2025-05-25 04:12:04.138381+00 |
| description | The implementation of trait Display |
| homepage | |
| repository | https://github.com/fuderis/rs-macron/tree/main/macron-impl-display |
| max_upload_size | |
| id | 1622971 |
| size | 13,906 |
The implementation of trait Display.
P.s.: More useful macros you can find here.
#[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'");
Distributed under the MIT license.
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.