Trait 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 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)

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl TList for TNil

Source§

const IS_EMPTY: bool = true

Source§

const LEN: usize = 0usize

Source§

type Concat<Rhs: TList> = Rhs

Source§

type Reverse = TNil

Source§

type IsEmpty = B1

Source§

type Len = UTerm

Source§

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

Source§

const IS_EMPTY: bool = false

Source§

const LEN: usize

Source§

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

Source§

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

Source§

type IsEmpty = B0

Source§

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