pub trait NonEmptyTuple: Tuple {
type Head;
type Tail;
type TruncateHead: GrowableTuple<Prepend<Self::Head> = Self>;
type TruncateTail: GrowableTuple<Append<Self::Tail> = Self>;
// Required methods
fn head(&self) -> &Self::Head;
fn head_mut(&mut self) -> &mut Self::Head;
fn tail(&self) -> &Self::Tail;
fn tail_mut(&mut self) -> &mut Self::Tail;
fn truncate_head(self) -> (Self::Head, Self::TruncateHead);
fn truncate_tail(self) -> (Self::TruncateTail, Self::Tail);
}Expand description
Tuples that are not empty. Implemented for sized tuples of arity 1 to 32.
Required Associated Types§
Sourcetype TruncateHead: GrowableTuple<Prepend<Self::Head> = Self>
type TruncateHead: GrowableTuple<Prepend<Self::Head> = Self>
This tuple with its head truncated.
Sourcetype TruncateTail: GrowableTuple<Append<Self::Tail> = Self>
type TruncateTail: GrowableTuple<Append<Self::Tail> = Self>
This tuple with its tail truncated.
Required Methods§
Sourcefn head(&self) -> &Self::Head
fn head(&self) -> &Self::Head
Returns a reference to the head of this tuple.
§Examples
let tuple = (1, 2, 3);
assert_eq!(&1, tuple.head());Sourcefn head_mut(&mut self) -> &mut Self::Head
fn head_mut(&mut self) -> &mut Self::Head
Returns a mutable reference to the head of this tuple.
§Examples
let mut tuple = (1, 2, 3);
assert_eq!(&mut 1, tuple.head_mut());Sourcefn tail(&self) -> &Self::Tail
fn tail(&self) -> &Self::Tail
Returns a reference to the tail of this tuple.
§Examples
let tuple = (1, 2, 3);
assert_eq!(&3, tuple.tail());Sourcefn tail_mut(&mut self) -> &mut Self::Tail
fn tail_mut(&mut self) -> &mut Self::Tail
Returns a mutable reference to the tail of this tuple.
§Examples
let mut tuple = (1, 2, 3);
assert_eq!(&mut 3, tuple.tail_mut());Sourcefn truncate_head(self) -> (Self::Head, Self::TruncateHead)
fn truncate_head(self) -> (Self::Head, Self::TruncateHead)
Consumes this tuple and truncates its head from the remaining elements.
§Examples
let tuple = (1, 2, 3);
let (head, tuple) = tuple.truncate_head();
assert_eq!((1, (2, 3)), (head, tuple));Sourcefn truncate_tail(self) -> (Self::TruncateTail, Self::Tail)
fn truncate_tail(self) -> (Self::TruncateTail, Self::Tail)
Consumes this tuple and truncates its tail from the remaining elements.
§Examples
let tuple = (1, 2, 3);
let (tuple, tail) = tuple.truncate_tail();
assert_eq!(((1, 2), 3), (tuple, tail));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.