Struct heapless::Vec [] [src]

pub struct Vec<T, A> where
    A: Unsize<[T]>, 
{ /* fields omitted */ }

A Vec, vector, backed by a fixed size array

Methods

impl<T, A> Vec<T, A> where
    A: Unsize<[T]>, 
[src]

[src]

Constructs a new, empty Vec<T> backed by the array A

[src]

Returns the maximum number of elements the vector can hold

[src]

Clears the vector, removing all values.

[src]

Clones and appends all elements in a slice to the Vec.

Iterates over the slice other, clones each element, and then appends it to this Vec. The other vector is traversed in-order.

Examples

use heapless::Vec;

let mut vec = Vec::<u8, [u8; 8]>::new();
vec.push(1).unwrap();
vec.extend_from_slice(&[2, 3, 4]).unwrap();
assert_eq!(*vec, [1, 2, 3, 4]);

[src]

Removes the last element from a vector and return it, or None if it's empty

[src]

Appends an element to the back of the collection

Returns BufferFullError if the vector is full

[src]

Shortens the vector, keeping the first len elements and dropping the rest.

[src]

Resizes the Vec in-place so that len is equal to new_len.

If new_len is greater than len, the Vec is extended by the difference, with each additional slot filled with value. If new_len is less than len, the Vec is simply truncated.

See also [resize_default].

[src]

Resizes the Vec in-place so that len is equal to new_len.

If new_len is greater than len, the Vec is extended by the difference, with each additional slot filled with Default::default(). If new_len is less than len, the Vec is simply truncated.

See also [resize].

[src]

Removes an element from the vector and returns it.

The removed element is replaced by the last element of the vector.

This does not preserve ordering, but is O(1).

Panics

Panics if index is out of bounds.

Examples

use heapless::Vec;

let mut v: Vec<_, [_; 8]> = Vec::new();
v.push("foo").unwrap();
v.push("bar").unwrap();
v.push("baz").unwrap();
v.push("qux").unwrap();

assert_eq!(v.swap_remove(1), "bar");
assert_eq!(&*v, ["foo", "qux", "baz"]);

assert_eq!(v.swap_remove(0), "foo");
assert_eq!(&*v, ["baz", "qux"]);

Trait Implementations

impl<T, A> Debug for Vec<T, A> where
    A: Unsize<[T]>,
    T: Debug
[src]

[src]

Formats the value using the given formatter. Read more

impl<T, A> Drop for Vec<T, A> where
    A: Unsize<[T]>, 
[src]

[src]

Executes the destructor for this type. Read more

impl<'a, T, A> IntoIterator for &'a Vec<T, A> where
    A: Unsize<[T]>, 
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl<'a, T, A> IntoIterator for &'a mut Vec<T, A> where
    A: Unsize<[T]>, 
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl<T, A, B> PartialEq<Vec<T, B>> for Vec<T, A> where
    A: Unsize<[T]>,
    B: Unsize<[T]>,
    T: PartialEq
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl<T, A> Eq for Vec<T, A> where
    A: Unsize<[T]>,
    T: Eq
[src]

impl<T, A> Deref for Vec<T, A> where
    A: Unsize<[T]>, 
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl<T, A> DerefMut for Vec<T, A> where
    A: Unsize<[T]>, 
[src]

[src]

Mutably dereferences the value.

impl<T, A> AsRef<Vec<T, A>> for Vec<T, A> where
    A: Unsize<[T]>, 
[src]

[src]

Performs the conversion.

impl<T, A> AsMut<Vec<T, A>> for Vec<T, A> where
    A: Unsize<[T]>, 
[src]

[src]

Performs the conversion.

impl<T, A> AsRef<[T]> for Vec<T, A> where
    A: Unsize<[T]>, 
[src]

[src]

Performs the conversion.

impl<T, A> AsMut<[T]> for Vec<T, A> where
    A: Unsize<[T]>, 
[src]

[src]

Performs the conversion.

Auto Trait Implementations

impl<T, A> Send for Vec<T, A> where
    A: Send,
    T: Send

impl<T, A> Sync for Vec<T, A> where
    A: Sync,
    T: Sync