Trait generic_array::sequence::Shorten [−][src]
pub unsafe trait Shorten<T>: Sized + GenericSequence<T> { type Shorter: Lengthen<T, Longer = Self>; fn pop_back(self) -> (Self::Shorter, T); fn pop_front(self) -> (T, Self::Shorter); }
Expand description
Defines a GenericSequence
which can be shortened by removing the first or last element from it.
Additionally, any shortened sequence can be lengthened by appending or prepending an element to it.
Associated Types
Required methods
Returns a new array without the last element, and the last element.
Example:
let a = arr![i32; 1, 2, 3, 4]; let (init, last) = a.pop_back(); assert_eq!(init, arr![i32; 1, 2, 3]); assert_eq!(last, 4);