Trait shrimple_parser::tuple::Tuple

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

Show 18 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 nth<const N: usize>(self) -> Self::Nth where Self: IndexTuple<N> { ... } fn nth_ref<const N: usize>(&self) -> &Self::Nth where Self: IndexTuple<N> { ... } fn map_nth<const N: usize, U>( self, f: impl FnOnce(Self::Nth) -> U ) -> Self::NthMapped<U> where Self: IndexTuple<N> { ... } fn first(self) -> Self::Nth where Self: IndexTuple<0> { ... } fn first_ref(&self) -> &Self::Nth where Self: IndexTuple<0> { ... } fn map_first<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U> where Self: IndexTuple<0> { ... } fn second(self) -> Self::Nth where Self: IndexTuple<1> { ... } fn second_ref(&self) -> &Self::Nth where Self: IndexTuple<1> { ... } fn map_second<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U> where Self: IndexTuple<1> { ... } fn third(self) -> Self::Nth where Self: IndexTuple<2> { ... } fn third_ref(&self) -> &Self::Nth where Self: IndexTuple<2> { ... } fn map_third<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U> where Self: IndexTuple<2> { ... } fn first_n<const N: usize>(self) -> Self::FirstN where Self: SliceTuple<N> { ... } fn strip_first_n<const N: usize>(self) -> Self::FirstNStripped where Self: SliceTuple<N> { ... } fn split<const N: usize>(self) -> (Self::FirstN, Self::FirstNStripped) where Self: SliceTuple<N> { ... }
}
Expand description

Trait for a generic tuple. Most methods in the trait have equivalents in the form of free-standing functions.

Required Associated Types§

source

type Appended<NewElement>

The tuple + a new element at the end.

source

type Prepended<NewElement>

The tuple + a new element at the start.

source

type Reversed

The tuple with its elements in reverse order.

Required Methods§

source

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

Adds new_element to the end of the tuple.

source

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

Adds new_element to the start of the tuple.

source

fn rev(self) -> Self::Reversed

Returns the tuple with its elements in reverse order.

Provided Methods§

source

fn nth<const N: usize>(self) -> Self::Nth
where Self: IndexTuple<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: IndexTuple<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: IndexTuple<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: IndexTuple<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: IndexTuple<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: IndexTuple<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: IndexTuple<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: IndexTuple<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: IndexTuple<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: IndexTuple<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: IndexTuple<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: IndexTuple<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: SliceTuple<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: SliceTuple<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: SliceTuple<N>,

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

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Tuple for ()

§

type Appended<NewElement> = (NewElement,)

§

type Prepended<NewElement> = (NewElement,)

§

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

§

type Appended<NewElement> = (T0, NewElement)

§

type Prepended<NewElement> = (NewElement, T0)

§

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)

§

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

§

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

§

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)

§

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

§

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

§

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)

§

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

§

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

§

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)

§

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

§

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

§

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)

§

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

§

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

§

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)

§

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

§

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

§

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)

§

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

§

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

§

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§