[][src]Struct staticvec::StaticVec

pub struct StaticVec<T, const N: usize> { /* fields omitted */ }

A Vec-like struct (directly API-compatible where it can be at least as far as function signatures go) implemented with const generics around a static array of fixed "N" capacity.

Methods

impl<T, const N: usize> StaticVec<T, { N }>[src]

pub fn new() -> Self[src]

Returns a new StaticVec instance.

pub fn len(&self) -> usize[src]

Returns the current length of the StaticVec. Just as for a normal Vec, this means the number of elements that have been added to it with "push", "insert", e.t.c.

pub const fn capacity(&self) -> usize[src]

Returns the total capacity of the StaticVec. This is always equivalent to the generic "N" parameter it was declared with, which determines the fixed size of the static backing array.

pub fn is_empty(&self) -> bool[src]

Returns true if the current length of the StaticVec is 0.

pub fn is_not_empty(&self) -> bool[src]

Returns true if the current length of the StaticVec is greater than 0.

pub fn is_full(&self) -> bool[src]

Returns true if the current length of the StaticVec is equal to its capacity.

pub fn is_not_full(&self) -> bool[src]

Returns true if the current length of the StaticVec is less than its capacity.

pub fn as_ptr(&self) -> *const T[src]

Returns a constant pointer to the first element of the StaticVec's internal array.

pub fn as_mut_ptr(&mut self) -> *mut T[src]

Returns a mutable pointer to the first element of the StaticVec's internal array.

pub fn as_slice(&self) -> &[T][src]

Returns a constant reference to a slice of the StaticVec's "inhabited" area.

pub fn as_mut_slice(&mut self) -> &mut [T][src]

Returns a mutable reference to a slice of the StaticVec's "inhabited" area.

pub fn push(&mut self, value: T)[src]

Asserts that the current length of the StaticVec is less than "N", and if so appends a value to the end of it.

pub fn pop(&mut self) -> Option<T>[src]

Removes the value at the last position of the StaticVec and returns it in "Some" if the StaticVec has a current length greater than 0, and "None" otherwise.

pub unsafe fn push_unchecked(&mut self, value: T)[src]

Appends a value to the end of the StaticVec without asserting that its current length is less than "N".

pub unsafe fn pop_unchecked(&mut self) -> T[src]

Pops a value from the end of the StaticVec and returns it directly without asserting that the StaticVec's current length is greater than 0.

pub fn remove(&mut self, index: usize) -> T[src]

Asserts that "index" is less than the current length of the StaticVec, and if so removes the value at that position and returns it. Any values that exist in later positions are shifted to the left.

pub fn insert(&mut self, index: usize, value: T)[src]

Asserts that the current length of the StaticVec is less than "N" and that "index" is less than the length, and if so inserts "value" at that position. Any values that exist in later positions are shifted to the right.

pub fn clear(&mut self)[src]

Removes all contents from the StaticVec and sets its length back to 0.

pub fn sort(&mut self) where
    T: Ord
[src]

Performs an unstable in-place sort of the StaticVec's "inhabited" area.

pub fn reverse(&mut self)[src]

Reverses the contents of the StaticVec's "inhabited" area in-place.

pub fn sorted(&mut self) -> Self where
    T: Copy + Ord
[src]

Returns a separate, sorted StaticVec of the contents of the StaticVec's "inhabited" area without modifying the original data.

pub fn reversed(&mut self) -> Self where
    T: Copy
[src]

Returns a separate, reversed StaticVec of the contents of the StaticVec's "inhabited" area without modifying the original data.

pub fn extend_from_slice(&mut self, other: &[T]) where
    T: Copy
[src]

Copies and appends all elements in a slice to the StaticVec. Unlike the implementation of this function for Vec, no iterator is used, just a single pointer-copy call.

pub fn drain<R>(&mut self, range: R) -> Self where
    R: RangeBounds<usize>, 
[src]

Removes the specified range of elements from the StaticVec and returns them in a new one.

Important traits for StaticVecIteratorConst<'a, T>
pub fn iter<'a>(&'a self) -> StaticVecIteratorConst<'a, T>[src]

Returns a StaticVecIteratorConst over the StaticVec's "inhabited" area.

Important traits for StaticVecIteratorMut<'a, T>
pub fn iter_mut<'a>(&'a mut self) -> StaticVecIteratorMut<'a, T>[src]

Returns a StaticVecIteratorMut over the StaticVec's "inhabited" area.

Trait Implementations

impl<'a, T: 'a, const N: usize> IntoIterator for &'a StaticVec<T, { N }>[src]

type IntoIter = StaticVecIteratorConst<'a, T>

Which kind of iterator are we turning this into?

type Item = <Self::IntoIter as Iterator>::Item

The type of the elements being iterated over.

fn into_iter(self) -> Self::IntoIter[src]

Returns a StaticVecIteratorConst over the StaticVec's "inhabited" area.

impl<'a, T: 'a, const N: usize> IntoIterator for &'a mut StaticVec<T, { N }>[src]

type IntoIter = StaticVecIteratorMut<'a, T>

Which kind of iterator are we turning this into?

type Item = <Self::IntoIter as Iterator>::Item

The type of the elements being iterated over.

fn into_iter(self) -> Self::IntoIter[src]

Returns a StaticVecIteratorMut over the StaticVec's "inhabited" area.

impl<T, const N: usize> Drop for StaticVec<T, { N }>[src]

fn drop(&mut self)[src]

Calls clear() through the StaticVec before dropping it.

impl<T, const N: usize> Index<usize> for StaticVec<T, { N }>[src]

type Output = T

The returned type after indexing.

fn index(&self, index: usize) -> &Self::Output[src]

Asserts that "index" is less than the current length of the StaticVec, as if so returns the value at that position as a constant reference.

impl<T, const N: usize> IndexMut<usize> for StaticVec<T, { N }>[src]

fn index_mut(&mut self, index: usize) -> &mut Self::Output[src]

Asserts that "index" is less than the current length of the StaticVec, as if so returns the value at that position as a mutable reference.

impl<T, const N: usize> FromIterator<T> for StaticVec<T, { N }>[src]

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self[src]

Attempts to create a new StaticVec instance of the specified capacity from "iter". If it has a size greater than the capacity, any contents after that point are ignored.

Auto Trait Implementations

impl<const N: usize, T> Sync for StaticVec<T, N> where
    T: Sync

impl<const N: usize, T> Send for StaticVec<T, N> where
    T: Send

impl<const N: usize, T> Unpin for StaticVec<T, N> where
    T: Unpin

impl<const N: usize, T> RefUnwindSafe for StaticVec<T, N> where
    T: RefUnwindSafe

impl<const N: usize, T> UnwindSafe for StaticVec<T, N> where
    T: UnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]