Trait shrimple_parser::tuple::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§
sourcetype Appended<NewElement>
type Appended<NewElement>
The tuple + a new element at the end, the result of Tuple::append
sourcetype Prepended<NewElement>
type Prepended<NewElement>
The tuple + a new element at the start, the result of Tuple::prepend
sourcetype Reversed
type Reversed
The tuple with its elements in reverse order, the result of Tuple::rev
Required Methods§
sourcefn append<NewElement>(
self,
new_element: NewElement
) -> Self::Appended<NewElement>
fn append<NewElement>( self, new_element: NewElement ) -> Self::Appended<NewElement>
Adds new_element to the end of the tuple.
Also see append
Provided Methods§
sourcefn cloned(self) -> Self::Clonedwhere
Self: CloneableRefs,
fn cloned(self) -> Self::Clonedwhere
Self: CloneableRefs,
Clones the tuple element-wise, e.g. turn (&T, &U) into (T, U)
Also see cloned
sourcefn copied(self) -> Self::Copiedwhere
Self: CopiableRefs,
fn copied(self) -> Self::Copiedwhere
Self: CopiableRefs,
Copies the tuple element-wise, e.g. turn (&T, &U) into (T, U)
Also see copied
sourcefn nth<const N: usize>(self) -> Self::Nthwhere
Self: Index<N>,
fn nth<const N: usize>(self) -> Self::Nthwhere
Self: Index<N>,
Returns the N-th element of the tuple.
For shortcuts see Tuple::first, Tuple::second, Tuple::third
sourcefn nth_ref<const N: usize>(&self) -> &Self::Nthwhere
Self: Index<N>,
fn nth_ref<const N: usize>(&self) -> &Self::Nthwhere
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
sourcefn map_nth<const N: usize, U>(
self,
f: impl FnOnce(Self::Nth) -> U
) -> Self::NthMapped<U>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>,
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
sourcefn first(self) -> Self::Nthwhere
Self: Index<0>,
fn first(self) -> Self::Nthwhere
Self: Index<0>,
Returns the first element of the tuple.
For a more generic function, see Tuple::nth
sourcefn first_ref(&self) -> &Self::Nthwhere
Self: Index<0>,
fn first_ref(&self) -> &Self::Nthwhere
Self: Index<0>,
Returns a reference to the first element of the tuple.
For a more generic function, see Tuple::nth_ref
sourcefn map_first<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U>where
Self: Index<0>,
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
sourcefn second(self) -> Self::Nthwhere
Self: Index<1>,
fn second(self) -> Self::Nthwhere
Self: Index<1>,
Returns the second element of the tuple.
For a more generic function, see Tuple::nth
sourcefn second_ref(&self) -> &Self::Nthwhere
Self: Index<1>,
fn second_ref(&self) -> &Self::Nthwhere
Self: Index<1>,
Returns a reference to the second element of the tuple.
For a more generic function, see Tuple::nth_ref
sourcefn map_second<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U>where
Self: Index<1>,
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
sourcefn third(self) -> Self::Nthwhere
Self: Index<2>,
fn third(self) -> Self::Nthwhere
Self: Index<2>,
Returns the third element of the tuple.
For a more generic function, see Tuple::nth
sourcefn third_ref(&self) -> &Self::Nthwhere
Self: Index<2>,
fn third_ref(&self) -> &Self::Nthwhere
Self: Index<2>,
Returns a reference to the third element of the tuple.
For a more generic function, see Tuple::nth_ref
sourcefn map_third<U>(self, f: impl FnOnce(Self::Nth) -> U) -> Self::NthMapped<U>where
Self: Index<2>,
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
sourcefn first_n<const N: usize>(self) -> Self::FirstNwhere
Self: Slice<N>,
fn first_n<const N: usize>(self) -> Self::FirstNwhere
Self: Slice<N>,
Returns a tuple that containing the first N elements of the original tuple. The other elements are discarded.
sourcefn strip_first_n<const N: usize>(self) -> Self::FirstNStrippedwhere
Self: Slice<N>,
fn strip_first_n<const N: usize>(self) -> Self::FirstNStrippedwhere
Self: Slice<N>,
Returns the original tuple with its first N elements discarded.
Logical complement of Tuple::first_n