[src]

Trait std::slice::OwnedCloneableVector

pub trait OwnedCloneableVector<T: Clone> {
    fn push_all(&mut self, rhs: &[T]);
    fn grow(&mut self, n: uint, initval: &T);
    fn grow_set(&mut self, index: uint, initval: &T, val: T);
}

Extension methods for owned vectors containing Clone elements.

Required Methods

fn push_all(&mut self, rhs: &[T])

Iterates over the slice rhs, copies each element, and then appends it to the vector provided v. The rhs vector is traversed in-order.

Example

let mut a = ~[1];
a.push_all([2, 3, 4]);
assert!(a == ~[1, 2, 3, 4]);

fn grow(&mut self, n: uint, initval: &T)

Expands a vector in place, initializing the new elements to a given value

Arguments

  • n - The number of elements to add
  • initval - The value for the new elements

fn grow_set(&mut self, index: uint, initval: &T, val: T)

Sets the value of a vector element at a given index, growing the vector as needed

Sets the element at position index to val. If index is past the end of the vector, expands the vector by replicating initval to fill the intervening space.

Implementors