Macro autoimpl::autoimpl
[−]
macro_rules! autoimpl { ProcMacroHackItem => { ... }; }
Generates a default blanket impl for a generic trait that gets passed into
autoimpl!
, with the same type parameters and type bounds as its trait.
Panics
- If a trait is not a generic trait
- If more than one trait gets passed into an
autoimpl!
block - If anything other than a trait gets passed into an
autoimpl!
block
Example
#[macro_use] extern crate autoimpl; struct Dog {} struct Duck {} fn main() { autoimpl! { trait Quack<T> { fn say(&self) -> String { "quack".to_string() } } } let dog = Dog {}; let duck = Duck {}; assert_eq!(dog.say(), duck.say()); }