Trait Tuple

Source
pub trait Tuple: Sized {
    type Appended<NewElement>;
    type Prepended<NewElement>;
    type Reversed;

Show 20 methods // Required methods fn append<NewElement>( self, new_element: NewElement, ) -> Self::Appended<NewElement>; fn prepend<NewElement>( self, new_element: NewElement, ) -> Self::Prepended<NewElement>; fn rev(self) -> Self::Reversed; // Provided methods fn cloned(self) -> Self::Cloned where Self: CloneableRefs { ... } fn copied(self) -> Self::Copied where Self: CopiableRefs { ... } fn nth<const N: usize>(self) -> Self::Nth where Self: Index<N> { ... } fn nth_ref<const N: usize>(&self) -> &Self::Nth where Self: Index<N> { ... } fn map_nth<const N: usize, U>( self, f: impl FnOnce(Self::Nth) -> U, ) -> Self::NthMapped<U> where Self: Index<N> { ... } fn first(self) -> Self::Nth where Self: Index<0> { ... } fn first_ref(&self) -> &Self::Nth where Self: Index<0> { ... } fn map_first<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U> where Self: Index<0> { ... } fn second(self) -> Self::Nth where Self: Index<1> { ... } fn second_ref(&self) -> &Self::Nth where Self: Index<1> { ... } fn map_second<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U> where Self: Index<1> { ... } fn third(self) -> Self::Nth where Self: Index<2> { ... } fn third_ref(&self) -> &Self::Nth where Self: Index<2> { ... } fn map_third<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U> where Self: Index<2> { ... } fn first_n<const N: usize>(self) -> Self::FirstN where Self: Slice<N> { ... } fn strip_first_n<const N: usize>(self) -> Self::FirstNStripped where Self: Slice<N> { ... } fn split<const N: usize>(self) -> (Self::FirstN, Self::FirstNStripped) where Self: Slice<N> { ... }
}
Expand description

Trait for a generic tuple.

Required Associated Types§

Source

type Appended<NewElement>

The tuple + a new element at the end, the result of Tuple::append

Source

type Prepended<NewElement>

The tuple + a new element at the start, the result of Tuple::prepend

Source

type Reversed

The tuple with its elements in reverse order, the result of Tuple::rev

Required Methods§

Source

fn append<NewElement>( self, new_element: NewElement, ) -> Self::Appended<NewElement>

Adds new_element to the end of the tuple. Also see append

Source

fn prepend<NewElement>( self, new_element: NewElement, ) -> Self::Prepended<NewElement>

Adds new_element to the start of the tuple. Also see prepend

Source

fn rev(self) -> Self::Reversed

Returns the tuple with its elements in reverse order. Also see rev

Provided Methods§

Source

fn cloned(self) -> Self::Cloned
where Self: CloneableRefs,

Clones the tuple element-wise, e.g. turn (&T, &U) into (T, U) Also see cloned

Source

fn copied(self) -> Self::Copied
where Self: CopiableRefs,

Copies the tuple element-wise, e.g. turn (&T, &U) into (T, U) Also see copied

Source

fn nth<const N: usize>(self) -> Self::Nth
where Self: Index<N>,

Returns the N-th element of the tuple. For shortcuts see Tuple::first, Tuple::second, Tuple::third

Source

fn nth_ref<const N: usize>(&self) -> &Self::Nth
where Self: Index<N>,

Returns a reference to the N-th element of the tuple. For shortcuts see Tuple::first_ref, Tuple::second_ref, Tuple::third_ref

Source

fn map_nth<const N: usize, U>( self, f: impl FnOnce(Self::Nth) -> U, ) -> Self::NthMapped<U>
where Self: Index<N>,

Returns a function that transforms the N-th element of a tuple with f. For common shortcuts, see Tuple::map_first, Tuple::map_second, Tuple::map_third

Source

fn first(self) -> Self::Nth
where Self: Index<0>,

Returns the first element of the tuple. For a more generic function, see Tuple::nth

Source

fn first_ref(&self) -> &Self::Nth
where Self: Index<0>,

Returns a reference to the first element of the tuple. For a more generic function, see Tuple::nth_ref

Source

fn map_first<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U>
where Self: Index<0>,

Transforms the first element of the tuple with f. For a more generic function, see Tuple::map_nth

Source

fn second(self) -> Self::Nth
where Self: Index<1>,

Returns the second element of the tuple. For a more generic function, see Tuple::nth

Source

fn second_ref(&self) -> &Self::Nth
where Self: Index<1>,

Returns a reference to the second element of the tuple. For a more generic function, see Tuple::nth_ref

Source

fn map_second<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U>
where Self: Index<1>,

Transforms the second element of the tuple with f. For a more generic function, see Tuple::map_nth

Source

fn third(self) -> Self::Nth
where Self: Index<2>,

Returns the third element of the tuple. For a more generic function, see Tuple::nth

Source

fn third_ref(&self) -> &Self::Nth
where Self: Index<2>,

Returns a reference to the third element of the tuple. For a more generic function, see Tuple::nth_ref

Source

fn map_third<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U>
where Self: Index<2>,

Transforms the third element of the tuple with f. For a more generic function, see Tuple::map_nth

Source

fn first_n<const N: usize>(self) -> Self::FirstN
where Self: Slice<N>,

Returns a tuple that containing the first N elements of the original tuple. The other elements are discarded.

Source

fn strip_first_n<const N: usize>(self) -> Self::FirstNStripped
where Self: Slice<N>,

Returns the original tuple with its first N elements discarded. Logical complement of Tuple::first_n

Source

fn split<const N: usize>(self) -> (Self::FirstN, Self::FirstNStripped)
where Self: Slice<N>,

Splits the tuple into one with the first N elements and one with the rest.

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 Tuple for ()

Source§

type Appended<NewElement> = (NewElement,)

Source§

type Prepended<NewElement> = (NewElement,)

Source§

type Reversed = ()

Source§

fn append<NewElement>( self, new_element: NewElement, ) -> Self::Appended<NewElement>

Source§

fn prepend<NewElement>( self, new_element: NewElement, ) -> Self::Prepended<NewElement>

Source§

fn rev(self) -> Self::Reversed

Source§

impl<T0> Tuple for (T0,)

Source§

type Appended<NewElement> = (T0, NewElement)

Source§

type Prepended<NewElement> = (NewElement, T0)

Source§

type Reversed = (T0,)

Source§

fn append<NewElement>( self, new_element: NewElement, ) -> Self::Appended<NewElement>

Source§

fn prepend<NewElement>( self, new_element: NewElement, ) -> Self::Prepended<NewElement>

Source§

fn rev(self) -> Self::Reversed

Source§

impl<T0, T1> Tuple for (T0, T1)

Source§

type Appended<NewElement> = (T0, T1, NewElement)

Source§

type Prepended<NewElement> = (NewElement, T0, T1)

Source§

type Reversed = (T1, T0)

Source§

fn append<NewElement>( self, new_element: NewElement, ) -> Self::Appended<NewElement>

Source§

fn prepend<NewElement>( self, new_element: NewElement, ) -> Self::Prepended<NewElement>

Source§

fn rev(self) -> Self::Reversed

Source§

impl<T0, T1, T2> Tuple for (T0, T1, T2)

Source§

type Appended<NewElement> = (T0, T1, T2, NewElement)

Source§

type Prepended<NewElement> = (NewElement, T0, T1, T2)

Source§

type Reversed = (T2, T1, T0)

Source§

fn append<NewElement>( self, new_element: NewElement, ) -> Self::Appended<NewElement>

Source§

fn prepend<NewElement>( self, new_element: NewElement, ) -> Self::Prepended<NewElement>

Source§

fn rev(self) -> Self::Reversed

Source§

impl<T0, T1, T2, T3> Tuple for (T0, T1, T2, T3)

Source§

type Appended<NewElement> = (T0, T1, T2, T3, NewElement)

Source§

type Prepended<NewElement> = (NewElement, T0, T1, T2, T3)

Source§

type Reversed = (T3, T2, T1, T0)

Source§

fn append<NewElement>( self, new_element: NewElement, ) -> Self::Appended<NewElement>

Source§

fn prepend<NewElement>( self, new_element: NewElement, ) -> Self::Prepended<NewElement>

Source§

fn rev(self) -> Self::Reversed

Source§

impl<T0, T1, T2, T3, T4> Tuple for (T0, T1, T2, T3, T4)

Source§

type Appended<NewElement> = (T0, T1, T2, T3, T4, NewElement)

Source§

type Prepended<NewElement> = (NewElement, T0, T1, T2, T3, T4)

Source§

type Reversed = (T4, T3, T2, T1, T0)

Source§

fn append<NewElement>( self, new_element: NewElement, ) -> Self::Appended<NewElement>

Source§

fn prepend<NewElement>( self, new_element: NewElement, ) -> Self::Prepended<NewElement>

Source§

fn rev(self) -> Self::Reversed

Source§

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

Source§

type Appended<NewElement> = (T0, T1, T2, T3, T4, T5, NewElement)

Source§

type Prepended<NewElement> = (NewElement, T0, T1, T2, T3, T4, T5)

Source§

type Reversed = (T5, T4, T3, T2, T1, T0)

Source§

fn append<NewElement>( self, new_element: NewElement, ) -> Self::Appended<NewElement>

Source§

fn prepend<NewElement>( self, new_element: NewElement, ) -> Self::Prepended<NewElement>

Source§

fn rev(self) -> Self::Reversed

Source§

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

Source§

type Appended<NewElement> = (T0, T1, T2, T3, T4, T5, T6, NewElement)

Source§

type Prepended<NewElement> = (NewElement, T0, T1, T2, T3, T4, T5, T6)

Source§

type Reversed = (T6, T5, T4, T3, T2, T1, T0)

Source§

fn append<NewElement>( self, new_element: NewElement, ) -> Self::Appended<NewElement>

Source§

fn prepend<NewElement>( self, new_element: NewElement, ) -> Self::Prepended<NewElement>

Source§

fn rev(self) -> Self::Reversed

Source§

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

Source§

type Appended<NewElement> = (T0, T1, T2, T3, T4, T5, T6, T7, NewElement)

Source§

type Prepended<NewElement> = (NewElement, T0, T1, T2, T3, T4, T5, T6, T7)

Source§

type Reversed = (T7, T6, T5, T4, T3, T2, T1, T0)

Source§

fn append<NewElement>( self, new_element: NewElement, ) -> Self::Appended<NewElement>

Source§

fn prepend<NewElement>( self, new_element: NewElement, ) -> Self::Prepended<NewElement>

Source§

fn rev(self) -> Self::Reversed

Implementors§