default-impl 0.1.0

A macro for implementing traits with their default implementations
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 1.89 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 103.45 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Mearkatz

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 {}