Trait array_tool::vec::Shift
[−]
[src]
pub trait Shift<T> { fn shift(&mut self) -> T; fn unshift(&mut self, other: T); }
Removes, or Adds, the first element of self.
Required Methods
fn shift(&mut self) -> T
Removes and returns the first item from the vector
Example
use array_tool::vec::Shift; let mut x = vec![0,1,2,3]; assert_eq!(x.shift(), 0); assert_eq!(x, vec![1,2,3]);
fn unshift(&mut self, other: T)
Insert item at the beginning of the vector. No return value.
Example
use array_tool::vec::Shift; let mut x = vec![1,2,3]; x.unshift(0); assert_eq!(x, vec![0,1,2,3]);