[][src]Struct max_size_vec::MaxSizeVec

pub struct MaxSizeVec<T, const SIZE: usize> { /* fields omitted */ }

This type of vector is called a max-sized vector, and reserves a fixed amount of space at its creation. Once created, there are no elements, but the amount of elements can increase until the buffer is full. When the buffer is full, and another element is attempted to be added, a panic happens describing the error. This vector has the vast majority of vector methods and traits that aren't allocation specfic (e.g. reserve isn't a method).

Implementations

impl<T, const SIZE: usize> MaxSizeVec<T, {SIZE}>[src]

pub fn new() -> MaxSizeVec<T, {SIZE}>[src]

Creates a new, empty max-size vector.

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

Pushes an element to the max-size vector.

pub fn pop(&mut self)[src]

Pops off an element from the max-size vector.

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

Gets the length of the max-size vector.

pub fn drain<'a, R: RangeBounds<usize>>(
    &'a mut self,
    range: R
) -> Drain<'a, T, {SIZE}>

Notable traits for Drain<'a, T, {SIZE}>

impl<'a, T, const SIZE: usize> Iterator for Drain<'a, T, {SIZE}> type Item = T;
[src]

Drains elements from the vector based on a range.

pub fn append<const OTHER_SIZE: usize>(
    &mut self,
    other: &mut MaxSizeVec<T, {OTHER_SIZE}>
)
[src]

Appends a max-size vector onto this one, making the other one empty.

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

Gets a mutable pointer to the base of this vector.

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

Gets a mutable slice that can be used to edit or read the elements of this vector.

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

This gets a pointer to the base of this vector.

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

Gets an immutable slice that can be used to read the elements of this vector

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

The capacity of this vector, i.e. the maximum number of elements that it can hold.

pub fn clear(&mut self)[src]

This clears the vector.

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

This inserts an element at an index in the vector,

pub fn truncate(&mut self, size: usize)[src]

This truncates a vector to a certain length.

pub fn resize_with(&mut self, size: usize, f: impl FnMut() -> T)[src]

This resizes a vector with one condition: if the size is larger than the vectors size, a closure passed will be called to fill in the missing parts.

pub fn retain(&mut self, predicate: impl FnMut(&T) -> bool)[src]

This removes all elements that don't fit a predicate, leaving the ones that fit it.

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

This removes an element from a vector at a certain index, while preserving order.

pub fn swap_remove(&mut self, index: usize)[src]

This swaps an element at an index with the last element and pops the vector, which messes up order, but successfully removes an element from the vector.

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

This checks to see whether or not the vector is empty.

impl<T: Clone, const SIZE: usize> MaxSizeVec<T, {SIZE}>[src]

pub fn resize(&mut self, size: usize, value: T)[src]

This resizes a vector with a value to fill in missing parts if the size is larger than the current size.

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

This extends a vector from a slice.

Trait Implementations

impl<T, const SIZE: usize> AsMut<[T]> for MaxSizeVec<T, {SIZE}>[src]

impl<T, const SIZE: usize> AsMut<MaxSizeVec<T, SIZE>> for MaxSizeVec<T, {SIZE}>[src]

impl<T, const SIZE: usize> AsRef<[T]> for MaxSizeVec<T, {SIZE}>[src]

impl<T, const SIZE: usize> AsRef<MaxSizeVec<T, SIZE>> for MaxSizeVec<T, {SIZE}>[src]

impl<T, const SIZE: usize> Borrow<[T]> for MaxSizeVec<T, {SIZE}>[src]

impl<T, const SIZE: usize> BorrowMut<[T]> for MaxSizeVec<T, {SIZE}>[src]

impl<T: Clone, const SIZE: usize> Clone for MaxSizeVec<T, {SIZE}>[src]

impl<T: Debug, const SIZE: usize> Debug for MaxSizeVec<T, {SIZE}>[src]

impl<T, const SIZE: usize> Deref for MaxSizeVec<T, {SIZE}>[src]

type Target = [T]

The resulting type after dereferencing.

impl<T, const SIZE: usize> DerefMut for MaxSizeVec<T, {SIZE}>[src]

impl<T, const SIZE: usize> Drop for MaxSizeVec<T, {SIZE}>[src]

impl<T: Eq, const SIZE: usize> Eq for MaxSizeVec<T, {SIZE}>[src]

impl<'a, T: 'a + Copy, const SIZE: usize> Extend<&'a T> for MaxSizeVec<T, {SIZE}>[src]

impl<T, const SIZE: usize> Extend<T> for MaxSizeVec<T, {SIZE}>[src]

impl<'a, T: Clone, const SIZE: usize> From<&'a [T]> for MaxSizeVec<T, {SIZE}>[src]

impl<'a, T: Clone, const SIZE: usize> From<&'a mut [T]> for MaxSizeVec<T, {SIZE}>[src]

impl<'a, const SIZE: usize> From<&'a str> for MaxSizeVec<u8, {SIZE}>[src]

impl<T, const SIZE: usize> FromIterator<T> for MaxSizeVec<T, {SIZE}>[src]

impl<T, const SIZE: usize> Index<usize> for MaxSizeVec<T, {SIZE}>[src]

type Output = T

The returned type after indexing.

impl<T, const SIZE: usize> IndexMut<usize> for MaxSizeVec<T, {SIZE}>[src]

impl<T, const SIZE: usize> IntoIterator for MaxSizeVec<T, {SIZE}>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = MaxSizeVecIter<T, {SIZE}>

Which kind of iterator are we turning this into?

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

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?

impl<T: Ord, const SIZE: usize> Ord for MaxSizeVec<T, {SIZE}>[src]

impl<T: PartialEq, const SIZE: usize, const OTHER: usize, '_> PartialEq<&'_ [T; OTHER]> for MaxSizeVec<T, {SIZE}>[src]

impl<T: PartialEq, const SIZE: usize, '_> PartialEq<&'_ [T]> for MaxSizeVec<T, {SIZE}>[src]

impl<T: PartialEq, const SIZE: usize, const OTHER: usize> PartialEq<[T; OTHER]> for MaxSizeVec<T, {SIZE}>[src]

impl<T: PartialEq, const SIZE: usize, const OTHER: usize> PartialEq<MaxSizeVec<T, OTHER>> for MaxSizeVec<T, {SIZE}>[src]

impl<T: PartialOrd, const SIZE: usize> PartialOrd<MaxSizeVec<T, SIZE>> for MaxSizeVec<T, {SIZE}>[src]

Auto Trait Implementations

impl<T, const SIZE: usize> Send for MaxSizeVec<T, SIZE> where
    T: Send

impl<T, const SIZE: usize> Sync for MaxSizeVec<T, SIZE> where
    T: Sync

impl<T, const SIZE: usize> Unpin for MaxSizeVec<T, SIZE> where
    T: Unpin

Blanket Implementations

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

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

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

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

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.