Trait idata::cont::IVec[][src]

pub trait IVec<T> {
    fn ipush(self, _: T) -> Self;
fn iappend(self, _: Vec<T>) -> Self;
fn ipop(self) -> (Option<T>, Self); }

Some operations to work with vectors

Required Methods

Push an element to a vector, and return the same vector

  extern crate idata;
  use idata::cont::IVec;

  fn main() {
       let v = vec![1, 2];
       let v = v.ipush(3)
                .ipush(4);

      assert!(v == vec![1,2,3,4]);
  }

Append a vector to another

  extern crate idata;
  use idata::cont::IVec;

  fn main() {
       let v1 = vec![1, 2];
       let v2 = vec![3, 4, 5];
       let v1 = v1.iappend(v2);

       assert!(v1 == vec![1,2,3,4, 5]);
  }

Remove an element from back of a vector

  extern crate idata;
  use idata::cont::IVec;

  fn main() {
       let v1 = vec![1, 2, 3, 4, 5, 6];
       let (o, v1) = v1.ipop();

       assert!(v1 == vec![1,2,3,4, 5]);
       assert!(o.unwrap() == 6);
  }

Implementations on Foreign Types

impl<T> IVec<T> for Vec<T>
[src]

Implementors