| Crates.io | default-impl |
| lib.rs | default-impl |
| version | 0.1.0 |
| created_at | 2024-01-20 21:22:31.13053+00 |
| updated_at | 2024-01-20 21:22:31.13053+00 |
| description | A macro for implementing traits with their default implementations |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1106819 |
| size | 2,205 |
A macro that expands to the default implementation of a trait on a collection of types.
trait Show: Display + Sized {
fn show(&self) {
println!("{self}");
}
}
// Uses the default implementation of Show to implement it on all the provided types.
default_impl!(Show, u8, u16, u32, String, isize);
what default_impl expands to in this case:
impl Show for u8 {}
impl Show for u16 {}
impl Show for u32 {}
impl Show for String {}
impl Show for isize {}