Module std::vec1.0.0 [] [src]

A contiguous growable array type with heap-allocated contents, written Vec<T> but pronounced 'vector.'

Vectors have O(1) indexing, amortized O(1) push (to the end) and O(1) pop (from the end).


You can explicitly create a Vec<T> with new():

let v: Vec<i32> = Vec::new();Run

...or by using the vec! macro:

let v: Vec<i32> = vec![];

let v = vec![1, 2, 3, 4, 5];

let v = vec![0; 10]; // ten zeroesRun

You can push values onto the end of a vector (which will grow the vector as needed):

let mut v = vec![1, 2];


Popping values works in much the same way:

let mut v = vec![1, 2];

let two = v.pop();Run

Vectors also support indexing (through the Index and IndexMut traits):

let mut v = vec![1, 2, 3];
let three = v[2];
v[1] = v[1] + 5;Run



A draining iterator for Vec<T>.


An iterator that moves out of a vector.


A contiguous growable array type, written Vec<T> but pronounced 'vector'.