mopa::mopafy!
[−]
[src]
macro_rules! mopafy { ($trait_:ty) => { ... }; ($trait_:ty, core = $core:ident) => { ... }; ($trait_:ty, core = $core:ident, alloc = $alloc:ident) => { ... }; }
The macro for implementing all the Any
methods on your own trait.
Instructions for use
Make sure your trait extends
Any
(e.g.trait Trait: Any { }
)Mopafy your trait (see the next subsection for specifics).
…
Profit!
Mopafication techniques
There are three ways of mopafying traits, depending on what libraries you are using.
If you are a normal person:
mopafy!(Trait);
If you are using libcore but not libstd (
#![no_std]
) or liballoc:mopafy!(Trait, core = core);
(This is akin to
mopafy!(Trait, core = std)
if you were using libstd.)Unlike the other two techniques, this only gets you the
&Any
and&mut Any
methods; theBox<Any>
methods require liballoc.If you are using libcore and liballoc but not libstd (
#![nostd]
):mopafy!(Trait, core = core, alloc = alloc);
(This is akin to
mopafy!(Trait, core = std, alloc = std)
if you were using libstd; in fact, the first form is just sugar for this very thing.)This gets you all the methods.