macro_rules! type_fn_impl {
{@a_or_else_b => } => { ... };
{@a_or_else_b => $($b:ident)+} => { ... };
{@a_or_else_b $($a:ty)+ => $($b:ident)*} => { ... };
{$(fn $name:ident <$($($arg:ident)? $(=> $($argv:ty)+)?),* $(| $($targ:ident),+)?>
$(where $($tv:ty : $( + $( ?$tcqm:ident )? $( $tc:ident )? )+ ,)+)? => $ret:ty;)+} => { ... };
}Expand description
Generates type-fn implementations.
Syntax:
fn<$FnType$> $name$<$args$> $[$where-clause$]$ => $return-type$;
FnType should simply be a trait containing type Ret, e.g. TypeFn.
args is a type-arg list. To pattern-match types, use T => Successor<T> to
implement something like like Add<Successor<T>, Rhs>.
When implementing something for a specific type, use => TypeHere (leave out
the type arg name).
If you need an extra type arg that wont be in the resulting type anywhere,
add a bar | and write type args there as normal.
The where clause is just like rust’s, except you need to put a plus before the first trait bound as well. Trailing commas are also mandatory. Trait bounds can only be set using the where-clause.
The return type can use any of the type arguments.
You can define an arbitrary amount of functions in one macro invocation.