macro_rules! subtype_of {
($base:ty => $sub:ty | $cerr:ty $check_fn:block) => { ... };
}
Expand description
Generation conversion traits for subtype of base.
Syntax:
subtype_of!(Base => Sub | Error { ... })
The macro generates four conversion traits for Sub
:
Deref<Target=Base>
forSub
TryFrom<Base, Err=Error>
forSub
TryFrom<&Base, Err=Error>
for&Sub
TryFrom<&mut Base, Err=Error>
for&mut Sub
All traits use the { ... }
block which must expand to a Result<(), Error>
to check whether or not a conversion is possible.