Trait rust_examples::dependent::HList[][src]

pub trait HList<N: Nat> {
    fn cons<H>(self, x: H) -> HCons<Succ<N>, N, H, Self>
    where
        Self: Sized
, { ... }
fn conctat<M, L, X, R>(self, _hlist: L) -> R
    where
        Self: Sized,
        M: Nat + AddEq<N, X>,
        L: HList<M>,
        X: Nat,
        R: HList<X>
, { ... }
fn len(&self) -> usize { ... } }
Expand description

Trait representing a heterogeneous list, a.k.a HList of length N.

Similarly to the simple example of Vector, a HList also depends on its length N.

Contrary to an ordinary list, elements of an HList (resp. HCons) may vary in types.

Example

// hlist = true : "two" : 1 : []
let hlist = HNil.cons(1).cons("two").cons(true);
assert_eq!(3, hlist.len());

Provided methods

Add given element to the front of this HList.

Concatenate this and given HList.

HList<M> ++ HList<N> = HList<M + N>

TODO: not implemented yet

Analogy to Vec::len.

Implementors

HNil is an empty HList (i.e. of length N = 0).

HCons<N, M, _, T> is a HList of length N > 0 if T is a HList of length M = N - 1.