pub trait TypeList: Copy + Clone {
// Required methods
fn contains<C: Sized + 'static>(self) -> bool;
fn for_each(self, v: &mut impl TypeVisitor);
// Provided methods
fn push<T: TS + 'static + ?Sized>(self) -> impl TypeList { ... }
fn extend(self, l: impl TypeList) -> impl TypeList { ... }
}
Expand description
A list containing types implementing TS + 'static + ?Sized
.
To construct a TypeList
, start with the empty list, which is the unit type ()
, and
repeatedly call TypeList::push
or TypeList::extend
on it.
Example:
fn primitives() -> impl TypeList {
let signed = ().push::<i8>().push::<i16>().push::<i32>().push::<i64>();
let unsigned = ().push::<u8>().push::<u16>().push::<u32>().push::<u64>();
().push::<char>()
.push::<bool>()
.extend(signed)
.extend(unsigned)
}
The only way to get access to the types contained in a TypeList
is to iterate over it by
creating a visitor implementing TypeVisitor
and calling TypeList::for_each
.
Under the hood, TypeList
is recursively defined as follows:
Required Methods§
fn contains<C: Sized + 'static>(self) -> bool
fn for_each(self, v: &mut impl TypeVisitor)
Provided Methods§
fn push<T: TS + 'static + ?Sized>(self) -> impl TypeList
fn extend(self, l: impl TypeList) -> impl TypeList
Object Safety§
This trait is not object safe.