Macro passthrough_trait_fn

Source
macro_rules! passthrough_trait_fn {
    { fn $name:ident($($param:ident: $type:ty),*) -> $ret:ty; } => { ... };
    { fn $name:ident(self$(, $param:ident: $type:ty)*) -> $ret:ty; } => { ... };
    { fn $name:ident(&self$(, $param:ident: $type:ty)*) -> $ret:ty; } => { ... };
    { fn $name:ident(&mut self$(, $param:ident: $type:ty)*) -> $ret:ty; } => { ... };
    { fn $name:ident(self$(, $param:ident: $type:ty)*); } => { ... };
    { fn $name:ident(&self$(, $param:ident: $type:ty)*); } => { ... };
    { fn $name:ident(&mut self$(, $param:ident: $type:ty)*); } => { ... };
}
Expand description

Implements a function as itself.

For traits that generalize interfaces that duplicate what we have on the struct itself, too. For example, we want to have IoVectorTrait, but not export it; requiring users to import that trait just for .len() is silly. So .len() is implemented directly on both IoVector and IoVectorMut – still, we want to have a generic IoVectorTrait::len(), too. This is what this macro implements.