[][src]Struct vec_option::VecOption

pub struct VecOption<T> { /* fields omitted */ }

A space optimized version of Vec<Option<T>> that stores the discriminant seperately

See crate-level docs for more information

Methods

impl<T> VecOption<T>[src]

pub fn new() -> Self[src]

Creates an empty vector, does not allocate

pub fn with_capacity(cap: usize) -> Self[src]

Creates an empty vector

allocates at least cap elements of space

pub fn reserve(&mut self, amount: usize)[src]

reserves at least amount elements

if there is already enough space, this does nothing

pub fn reserve_exact(&mut self, amount: usize)[src]

reserves exactly amount elements

if there is already enough space, this does nothing

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

The length of this vector

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

The capacity of the vector

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

Is this vector empty

pub fn push<V: Into<Option<T>>>(&mut self, value: V)[src]

Put a value at the end of the vector

Reallocates if there is not enough space

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

Remove the last element of the vector

returns None if the vector is empty

pub fn get_mut(&mut self, index: usize) -> Option<OptionProxy<T>>[src]

Returns a proxy to a mutable reference to the element at index or None if out of bounds.

pub fn get(&self, index: usize) -> Option<Option<&T>>[src]

Returns a reference to the element at index or None if out of bounds.

pub fn swap(&mut self, a: usize, b: usize)[src]

Swaps two elements of the vector, panics if either index is out of bounds

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

Returns the element at index or None if out of bounds.

Replaces the element at index with None.

pub fn replace<O: Into<Option<T>>>(
    &mut self,
    index: usize,
    value: O
) -> Option<Option<T>>
[src]

Replace the element at index with value

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

Reduces the length of the vector to len and drops all excess elements

If len is greater than the length of the vector, nothing happens

pub fn clear(&mut self)[src]

Clears the vector

pub fn set_all_none(&mut self)[src]

Sets all of the elements in the vector to None and drops all values in the closure

pub fn extend_none(&mut self, additional: usize)[src]

Extends the vector with additional number of Nones

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

returns an iterator over references to the elements in the vector

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

returns an iterator over mutable references to the elements in the vector

pub fn try_fold<Range: RangeBounds<usize>, A, B, F: FnMut(A, usize, &mut Option<T>) -> Result<A, B>>(
    &mut self,
    range: Range,
    init: A,
    f: F
) -> Result<A, B> where
    Range: SliceIndex<[MaybeUninit<T>], Output = [MaybeUninit<T>]>, 
[src]

Iterates over all of the Option<T>s in the vector and applies the closure to each one of them until the closure returns Err(..), then iteration ends

The closure is passed the init, index, and a mutable reference to the corrosponding element of the vector

This is similar to Iterator::try_fold

pub fn fold<Range: RangeBounds<usize>, A, F: FnMut(A, usize, &mut Option<T>) -> A>(
    &mut self,
    range: Range,
    init: A,
    f: F
) -> A where
    Range: SliceIndex<[MaybeUninit<T>], Output = [MaybeUninit<T>]>, 
[src]

Iterates over all of the Option<T>s in the vector and applies the closure to each one

The closure is passed the init, index, and a mutable reference to the corrosponding element of the vector

This is similar to Iterator::fold

pub fn try_for_each<Range: RangeBounds<usize>, B, F: FnMut(usize, &mut Option<T>) -> Result<(), B>>(
    &mut self,
    range: Range,
    f: F
) -> Result<(), B> where
    Range: SliceIndex<[MaybeUninit<T>], Output = [MaybeUninit<T>]>, 
[src]

Iterates over all of the Option<T>s in the vector and applies the closure to each one of them until the closure returns Err(..), then iteration ends

The closure is passed the index, and a mutable reference to the corrosponding element of the vector

This is similar to Iterator::try_for_each

pub fn for_each<Range: RangeBounds<usize>, F: FnMut(usize, &mut Option<T>)>(
    &mut self,
    range: Range,
    f: F
) where
    Range: SliceIndex<[MaybeUninit<T>], Output = [MaybeUninit<T>]>, 
[src]

Iterates over all of the Option<T>s in the vector and applies the closure to each one

The closure is passed the index, and a mutable reference to the corrosponding element of the vector

This is similar to Iterator::for_each

Trait Implementations

impl<T> Default for VecOption<T>[src]

impl<T> Drop for VecOption<T>[src]

impl<T: Ord> Ord for VecOption<T>[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl<T: Clone> Clone for VecOption<T>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T: PartialEq> PartialEq<VecOption<T>> for VecOption<T>[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<T: PartialEq> PartialEq<[T]> for VecOption<T>[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<T: PartialEq, S: AsRef<[Option<T>]>> PartialEq<S> for VecOption<T>[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<T> Extend<Option<T>> for VecOption<T>[src]

impl<T> Extend<T> for VecOption<T>[src]

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

impl<T> From<Vec<Option<T>>> for VecOption<T>[src]

impl<T: Eq> Eq for VecOption<T>[src]

impl<T> IntoIterator for VecOption<T>[src]

type Item = Option<T>

The type of the elements being iterated over.

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?

impl<'a, T> IntoIterator for &'a mut VecOption<T>[src]

type Item = OptionProxy<'a, T>

The type of the elements being iterated over.

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?

impl<'a, T> IntoIterator for &'a VecOption<T>[src]

type Item = Option<&'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: PartialOrd> PartialOrd<VecOption<T>> for VecOption<T>[src]

#[must_use] fn lt(&self, other: &Rhs) -> bool1.0.0[src]

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

#[must_use] fn le(&self, other: &Rhs) -> bool1.0.0[src]

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

#[must_use] fn gt(&self, other: &Rhs) -> bool1.0.0[src]

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

#[must_use] fn ge(&self, other: &Rhs) -> bool1.0.0[src]

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

impl<T: Debug> Debug for VecOption<T>[src]

impl<T: Hash> Hash for VecOption<T>[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

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

impl<T> FromIterator<Option<T>> for VecOption<T>[src]

Auto Trait Implementations

impl<T> Sync for VecOption<T> where
    T: Sync

impl<T> Unpin for VecOption<T> where
    T: Unpin

impl<T> Send for VecOption<T> where
    T: Send

impl<T> UnwindSafe for VecOption<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for VecOption<T> where
    T: RefUnwindSafe

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for 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.

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

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

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