macro_rules! mopafy {
($trait_:ident) => { ... };
($trait_:ident, only core) => { ... };
}Expand description
The macro for implementing all the Any methods on your own trait.
§Instructions for use
-
Make sure your trait extends
mopa::Any(e.g.trait Trait: mopa::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:
trait Trait: mopa::Any { } mopafy!(Trait); -
If you are using libcore but not libstd (
#![no_std]) or liballoc, write this:mopafy!(Trait, only core);Unlike the other two techniques, this only gets you the
&Anyand&mut Anymethods; theBox<Any>methods require liballoc. -
If you are using libcore and liballoc but not libstd (
#![no_std]), bringalloc::boxed::Boxinto scope and usemopafy!as usual:ⓘuse alloc::boxed::Box; mopafy!(Trait);