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