pub trait OrdesRest {
type Newlen;
type Output;
// Required method
fn rest(self) -> (Self::Newlen, Self::Output);
}
Expand description
Trait for defining the removal of the first element from an array- or tuple-like data structure.
Required Associated Types§
Required Methods§
sourcefn rest(self) -> (Self::Newlen, Self::Output)
fn rest(self) -> (Self::Newlen, Self::Output)
Removes the first element from self
and returns it.
Examples
Using an array:
let foo: [u8; 5] = [0, 1, 2, 3, 4];
let (foo, pop) = foo.rest();
assert_eq!(foo, [1, 2, 3, 4]);
assert_eq!(pop, 0);
Using a tuple:
let foo = ('a', false, b'c', "d");
let (foo, pop) = foo.rest();
assert_eq!(foo, (false, b'c', "d"));
assert_eq!(pop, 'a');