TupleCons

Trait TupleCons 

Source
pub trait TupleCons<Head>: Tuple {
    type ConsResult: Tuple;

    // Required method
    fn cons(head: Head, tail: Self) -> Self::ConsResult;
}
Expand description

Trait providing tuple construction function, allows to prepend a value to a tuple.

Required Associated Types§

Source

type ConsResult: Tuple

Tuple with Head prepended to Self

Required Methods§

Source

fn cons(head: Head, tail: Self) -> Self::ConsResult

Constructs a tuple from head value and tail tuple by prepending head to tail.

Reverse of NonEmptyTuple::uncons.

§Examples
use tuple_list::TupleCons;
 
let a = TupleCons::cons("foo", ());
assert_eq!(
    a,
    ("foo",),
);
 
let b = TupleCons::cons(false, a);
assert_eq!(
    b,
    (false, "foo"),
);
 
let c = TupleCons::cons(4, b);
assert_eq!(
    c,
    (4, false, "foo"),
);

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.

Implementations on Foreign Types§

Source§

impl<T1> TupleCons<T1> for ()

Source§

type ConsResult = (T1,)

Source§

fn cons(head: T1, tail: Self) -> Self::ConsResult

Source§

impl<T1, T2> TupleCons<T1> for (T2,)

Source§

type ConsResult = (T1, T2)

Source§

fn cons(head: T1, tail: Self) -> Self::ConsResult

Source§

impl<T1, T2, T3> TupleCons<T1> for (T2, T3)

Source§

type ConsResult = (T1, T2, T3)

Source§

fn cons(head: T1, tail: Self) -> Self::ConsResult

Source§

impl<T1, T2, T3, T4> TupleCons<T1> for (T2, T3, T4)

Source§

type ConsResult = (T1, T2, T3, T4)

Source§

fn cons(head: T1, tail: Self) -> Self::ConsResult

Source§

impl<T1, T2, T3, T4, T5> TupleCons<T1> for (T2, T3, T4, T5)

Source§

type ConsResult = (T1, T2, T3, T4, T5)

Source§

fn cons(head: T1, tail: Self) -> Self::ConsResult

Source§

impl<T1, T2, T3, T4, T5, T6> TupleCons<T1> for (T2, T3, T4, T5, T6)

Source§

type ConsResult = (T1, T2, T3, T4, T5, T6)

Source§

fn cons(head: T1, tail: Self) -> Self::ConsResult

Source§

impl<T1, T2, T3, T4, T5, T6, T7> TupleCons<T1> for (T2, T3, T4, T5, T6, T7)

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8> TupleCons<T1> for (T2, T3, T4, T5, T6, T7, T8)

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9> TupleCons<T1> for (T2, T3, T4, T5, T6, T7, T8, T9)

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> TupleCons<T1> for (T2, T3, T4, T5, T6, T7, T8, T9, T10)

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> TupleCons<T1> for (T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> TupleCons<T1> for (T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)

Implementors§