Struct sized_vec::Vec[][src]

pub struct Vec<N, A> where
    N: Unsigned
{ /* fields omitted */ }

A vector of length N containing elements of type A.

Methods

impl<A> Vec<U0, A>
[src]

Construct an empty vector.

impl<N, A> Vec<N, A> where
    N: Unsigned
[src]

Push an element onto the end of the vector.

Pop an element off the end of the vector.

Insert an element into the vector at index Index.

Remove the element at index Index from the vector.

Remove the element at index Index from the vector, replacing it with the element at the end of the vector.

Append two vectors together.

Get a reference to the element at index Index.

Get a mutable reference to the element at index Index.

Get the length of the vector.

Test if the vector is empty.

Get an iterator over the elements of the vector.

Get a mutable iterator over the elements of the vector.

Get a reference to the slice of elements contained in the vector.

Get a mutable reference to the slice of elements contained in the vector.

Truncate the vector to fit the size given by the target type.

Examples

let vec_6 = svec![1, 2, 3, 4, 5, 6];
let vec_3: Vec<U3, _> = vec_6.truncate();
assert_eq!(svec![1, 2, 3], vec_3);

Slice a subset out of the vector.

Examples

let vec = svec![1, 2, 3, 4, 5, 6];
let (vec, sub_vec) = vec.slice(Range::<U2, U4>::new());
assert_eq!(svec![1, 2, 5, 6], vec);
assert_eq!(svec![3, 4], sub_vec);

Remove a subset from the vector and return an iterator over the removed elements.

Examples

let vec = svec![1, 2, 3, 4, 5, 6];
let (vec, iter) = vec.drain(Range::<U2, U4>::new());
assert_eq!(svec![1, 2, 5, 6], vec);
assert_eq!(vec![3, 4], iter.collect::<::std::vec::Vec<_>>());

Drop the contents of the vector, leaving an empty vector.

Split the vector at Index, returning the two sides of the split.

Examples

let vec = svec![1, 2, 3, 4, 5, 6];
let (left, right) = vec.split_off(U3::new());
assert_eq!(svec![1, 2, 3], left);
assert_eq!(svec![4, 5, 6], right);

Resize the vector, dropping elements if the new size is smaller, and padding with copies of value if it is larger.

Examples

let vec = svec![1, 2, 3];
let vec: Vec<U5, _> = vec.resize(100);
assert_eq!(svec![1, 2, 3, 100, 100], vec);

Map the vector into a vector of elements of B using a function.

Examples

let vec = svec![1, 2, 3];
let vec = vec.map(|num| format!("{}", num));
assert_eq!(svec![
    "1".to_string(), "2".to_string(), "3".to_string()
], vec);

Merge two vectors together into a new vector using a function.

Examples

let left = svec!["foo", "bar"];
let right = svec!["lol", "omg"];
let vec = left.zip(right, |a, b| format!("{} {}", a, b));
assert_eq!(svec![
    "foo lol".to_string(), "bar omg".to_string()
], vec);

Split a vector into two vectors of the same size using a function.

Examples

let left = svec!["foo", "bar"];
let right = svec!["lol", "omg"];
let vec = left.zip(right, |a, b| format!("{} {}", a, b));
assert_eq!(svec![
    "foo lol".to_string(), "bar omg".to_string()
], vec);

Trait Implementations

impl<N: PartialEq, A: PartialEq> PartialEq for Vec<N, A> where
    N: Unsigned
[src]

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

This method tests for !=.

impl<N: Eq, A: Eq> Eq for Vec<N, A> where
    N: Unsigned
[src]

impl<N: Clone, A: Clone> Clone for Vec<N, A> where
    N: Unsigned
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<N: Hash, A: Hash> Hash for Vec<N, A> where
    N: Unsigned
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<N: PartialOrd, A: PartialOrd> PartialOrd for Vec<N, A> where
    N: Unsigned
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<N: Ord, A: Ord> Ord for Vec<N, A> where
    N: Unsigned
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl<A> Default for Vec<U0, A>
[src]

Returns the "default value" for a type. Read more

impl<N, A> Debug for Vec<N, A> where
    N: Unsigned,
    A: Debug
[src]

Formats the value using the given formatter. Read more

impl<N, M, A> Add<Vec<M, A>> for Vec<N, A> where
    N: Unsigned + Add<M>,
    M: Unsigned,
    Sum<N, M>: Unsigned
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl<N, A> IntoIterator for Vec<N, A> where
    N: Unsigned
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl<N, A> Borrow<[A]> for Vec<N, A> where
    N: Unsigned
[src]

Immutably borrows from an owned value. Read more

impl<N, A> BorrowMut<[A]> for Vec<N, A> where
    N: Unsigned
[src]

Mutably borrows from an owned value. Read more

impl<N, A, I> Index<I> for Vec<N, A> where
    N: Unsigned,
    I: Unsigned + IsLess<N>,
    Le<I, N>: IsTrue
[src]

The returned type after indexing.

Performs the indexing (container[index]) operation.

impl<N, A, I> IndexMut<I> for Vec<N, A> where
    N: Unsigned,
    I: Unsigned + IsLess<N>,
    Le<I, N>: IsTrue
[src]

Performs the mutable indexing (container[index]) operation.

impl<N, A> AsRef<[A]> for Vec<N, A> where
    N: Unsigned
[src]

Performs the conversion.

impl<N, A> AsRef<Vec<N, A>> for Vec<N, A> where
    N: Unsigned
[src]

Performs the conversion.

impl<N, A> AsMut<[A]> for Vec<N, A> where
    N: Unsigned
[src]

Performs the conversion.

impl<N, A> AsMut<Vec<N, A>> for Vec<N, A> where
    N: Unsigned
[src]

Performs the conversion.

Auto Trait Implementations

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

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