OptArrayVec

Struct OptArrayVec 

Source
pub struct OptArrayVec<T, const N: usize> { /* private fields */ }
Expand description

A vector-like container that does not store its length directly, but rather retrieves them through inner options I highly discourage using this if size_of::<Yourtype> != size_of::<Option<Yourtype>>

Implementations§

Source§

impl<T, const CAP: usize> OptArrayVec<T, CAP>

Source

pub fn cap(&self) -> usize

Source

pub fn len(&self) -> usize

Amount of elements in the vec

§Complexity

Runtime is O(CAP) worst case

Source

pub fn is_empty(&self) -> bool

Source

pub const fn new() -> Self

Create a new empty vec CAP must be provided for how many elements can be stored

Source

pub fn push(&mut self, element: T)

Pushes new element at the back of the vec

§Complexity

Runtime is O(CAP) worst case

§Panics

When the len == CAP

Source

pub fn clear(&mut self)

Removes all elements from the vec

Source

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

Removes last element from the vec and return it If the vec is empty None is returned instead

Source

pub fn into_inner(self) -> [Option<T>; CAP]

Returns contents as they are stored internally

Source

pub fn remaining_capacity(&self) -> usize

Returns capacity still remaining

Source§

impl<T, const CAP: usize> OptArrayVec<T, CAP>

Source

pub fn iter(&self) -> Iter<'_, T>

Trait Implementations§

Source§

impl<T: Clone, const N: usize> Clone for OptArrayVec<T, N>

Source§

fn clone(&self) -> OptArrayVec<T, N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, const N: usize> Debug for OptArrayVec<T, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, const CAP: usize> Default for OptArrayVec<T, CAP>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T, const CAP: usize> Extend<T> for OptArrayVec<T, CAP>

Source§

fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)

Appends iterator to Self

§Panics

When the iterator yields more elements than there is remaining space

Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T, const CAP: usize> FromIterator<T> for OptArrayVec<T, CAP>

Source§

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

Create a vec from an iterator.

§Panics

When the iterator yields more elements than CAP

Source§

impl<T, const CAP: usize> Index<usize> for OptArrayVec<T, CAP>

Source§

type Output = T

The returned type after indexing.
Source§

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

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, const CAP: usize> IndexMut<usize> for OptArrayVec<T, CAP>

Source§

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

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, T, const CAP: usize> IntoIterator for &'a OptArrayVec<T, CAP>

Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T, const CAP: usize> IntoIterator for OptArrayVec<T, CAP>

Source§

type IntoIter = IntoIter<T, CAP>

Which kind of iterator are we turning this into?
Source§

type Item = T

The type of the elements being iterated over.
Source§

fn into_iter(self) -> IntoIter<T, CAP>

Creates an iterator from a value. Read more
Source§

impl<T: Copy, const N: usize> Copy for OptArrayVec<T, N>

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for OptArrayVec<T, N>
where T: Freeze,

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.