default-impl

Crates.iodefault-impl
lib.rsdefault-impl
version0.1.0
sourcesrc
created_at2024-01-20 21:22:31.13053
updated_at2024-01-20 21:22:31.13053
descriptionA macro for implementing traits with their default implementations
homepage
repository
max_upload_size
id1106819
size2,205
Beetle (Mearkatz)

documentation

README

A macro that expands to the default implementation of a trait on a collection of types.

Example

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 {}
Commit count: 0

cargo fmt