Struct anyvec::AnyVec [] [src]

pub struct AnyVec {
    // some fields omitted
}

A growable list type with dynamic typing.

It can store anything that implements the Any trait.

Methods

impl AnyVec
[src]

fn new() -> Self

Constructs a new, empty AnyVec.

fn with_capacity(capacity: usize, avg_type_size: usize) -> Self

Constructs a new, empty AnyVec with specified capacity.

Since we do not type sizes ahead, an average type size avg_type_size must be specified.

fn capacity(&self, type_size: usize) -> usize

Returns the number of elements the vector can hold without reallocating.

fn reserve(&mut self, additional: usize, avg_type_size: usize)

Reserves capacity for at least additional more elements.

Since we do not type sizes ahead, an average type size avg_type_size must be specified.

Panics

Panics if the new capacity overflows usize.

fn reserve_exact(&mut self, additional: usize, avg_type_size: usize)

Reserves capacity for exactly additional more elements.

Since we do not type sizes ahead, an average type size avg_type_size must be specified.

Panics

Panics if the new capacity overflows usize.

fn shrink_to_fit(&mut self)

Shrinks the capacity of the vector as much as possible.

fn truncate(&mut self, len: usize)

Shortens the vector to be len elements long.

fn insert<T: Any>(&mut self, index: usize, element: T)

Inserts an element at position index in the vector.

Shifts elements after position index to the right.

Panics

Panics if index is greater than the vector's length.

fn remove_and_return<T: Any>(&mut self, index: usize) -> Result<T, String>

Removes and returns the element at position index.

Shifts elements after position index to the left.

Panics

Panics if index is out of bounds.

fn remove(&mut self, index: usize)

Removes and returns the element at position index.

Shifts elements after position index to the left.

Panics

Panics if index is out of bounds.

fn is<T: Any>(&self, index: usize) -> Option<bool>

Returns if element at position index is of type T, or None if the index is out of bounds.

fn get<T: Any>(&self, index: usize) -> Result<Option<&T>, String>

Returns element at position index or None if the index is out of bounds.

fn get_mut<T: Any>(&self, index: usize) -> Result<Option<&mut T>, String>

Returns mutable reference to element at position index, or None if the index is out of bounds.

fn push<T: Any>(&mut self, value: T)

Appends an element to the back of a collection.

Panics

Panics if the number of elements in the vector overflows a usize.

fn pop<T: Any>(&mut self) -> Result<Option<T>, String>

Returns the last element of the vector, or None if it is empty.

fn append(&mut self, other: &mut AnyVec)

Moves all the elements of other into Self, leaving other empty.

Panics

Panics if the number of elements in the vector overflows a usize.

fn clear(&mut self)

Clears the vector.

fn len(&self) -> usize

Returns the number of elements in the vector.

fn is_empty(&self) -> bool

Returns if the vector is empty.

fn split_off(&mut self, at: usize) -> Self

Splits the collection into two at the given index.

Panics

Panics if at > len.

Trait Implementations

impl Debug for AnyVec
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.