macro_rules! typemap {
() => { ... };
($ty:ty = $val:expr, $($rest:tt)* ) => { ... };
($ty:ty = $val:expr) => { ... };
(..$final:expr) => { ... };
}
Expand description
Helper for creating a value of a typemap.
Takes a comma separated list of expressions of the form Type = expr
,
optionally followed by a single expr representing the rest of the list in the form ..rest
.
Expressions have core::convert::Into::into
called on them implicitly
For instance,
let example = typemap!(u16 = 2u16, u8 = 1u8);
let _ = typemap!(u64 = 4u64, u32 = 3u32, ..&example);
is equivilant to:
let example = Ty::<u16, _>::new(2u16.into(), Ty::<u8, _>::new(1u8.into(), TyEnd));
let _ = Ty::<u64, _>::new(4u64.into(), Ty::<u32, _>::new(3u32, &example));