Trait tlist::TList

source ·
pub trait TList: Sealed + TListImpl {
    type Concat<Rhs: TList>: TList;
    type Reverse: TList;
    type IsEmpty: Bit;
    type Len: UnsignedExt;

    const IS_EMPTY: bool;
    const LEN: usize;
}
Expand description

Type-level lists.

This trait is a “type-level enum”. TList, TNil and TCons are the type-level equivalent of the following value-level enum:

pub enum List<H, T> {
  Nil,
  Cons(H, T),
}

This trait can be considered a ‘marker’ trait: It has no methods to be called at runtime. It only has some GATs.

Rather than calling these GATs directly, it is recommended to instead use their type aliases, as calling those is less verbose:

use tlist::*;

// This is possible...
type Fine = <TList![u8, u16] as TList>::Concat<TList![u32, u64]>;

// But this is more readable:
type Nice = Concat<TList![u8, u16], TList![u32, u64]>;

static_assertions::assert_type_eq_all!(Fine, Nice);

Required Associated Types§

source

type Concat<Rhs: TList>: TList

Implementation of Concat.

source

type Reverse: TList

Implementation of Reverse.

source

type IsEmpty: Bit

Available on crate feature typenum only.

Implementation of IsEmpty.

source

type Len: UnsignedExt

Available on crate feature typenum only.

Implementation of Len.

Required Associated Constants§

source

const IS_EMPTY: bool

True iff the list is empty, false otherwise.

Returns a bool as associated const value. If you’d rather use a type, see IsEmpty (which needs typenum feature to be enabled)

Also see the Empty and NonEmpty traits.

source

const LEN: usize

The amount of elements in the list.

Returns an usize as associated const value. If you’d rather use a type, see Len (which needs typenum feature to be enabled)

Implementors§

source§

impl TList for TNil

§

type Concat<Rhs: TList> = Rhs

§

type Reverse = TNil

§

type IsEmpty = B1

§

type Len = UTerm

source§

const IS_EMPTY: bool = true

source§

const LEN: usize = 0usize

source§

impl<H, T: TList> TList for TCons<H, T>

§

type Concat<Rhs: TList> = TCons<H, <T as TList>::Concat<Rhs>>

§

type Reverse = <<T as TList>::Reverse as TList>::Concat<TCons<H, TNil>>

§

type IsEmpty = B0

§

type Len = <<T as TList>::Len as UnsignedExt>::Succ

source§

const IS_EMPTY: bool = false

source§

const LEN: usize = _