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
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.