Struct os1::vec::Vec [] [src]

pub struct Vec<T> {
    buf: RawVec<T>,
    len: usize,
}

A vector implementation. - Amortized O(1) push to end - O(1) pop from end - O(1) access to any element - Automatic memory management - Indexable with [] operator

Fields

buf
len

Methods

impl<T> Vec<T>

fn new() -> Vec<T>

Create a new empty vector

fn push(&mut self, val: T)

Push the element to the end

fn pop(&mut self) -> Option<T>

Pop and return the last element

fn len(&self) -> usize

Return the number of elements

fn truncate(&mut self, len: usize)

Shorten a vector to be len elements long, dropping excess elements.

If len is greater than the vector's current length, this has no effect.

Examples

let mut vec = vec![1, 2, 3, 4, 5];
vec.truncate(2);
assert_eq!(vec, [1, 2]);

Trait Implementations

impl<T> Index<usize> for Vec<T>

type Output = T

fn index<'a>(&'a self, index: usize) -> &'a T

impl<T> IndexMut<usize> for Vec<T>

fn index_mut<'a>(&'a mut self, index: usize) -> &'a mut T

impl<T> Drop for Vec<T>

fn drop(&mut self)

impl<T> Deref for Vec<T>

type Target = [T]

fn deref(&self) -> &[T]

impl<T> DerefMut for Vec<T>

fn deref_mut(&mut self) -> &mut [T]

impl<T: Clone> Clone for Vec<T>

fn clone(&self) -> Vec<T>

fn clone_from(&mut self, other: &Vec<T>)

impl<T> IntoIterator for Vec<T>

Barrowed from libstd

type Item = T

type IntoIter = IntoIter<T>

fn into_iter(self) -> IntoIter<T>