Enum opt_struct::vec::OptVec

source ·
pub enum OptVec<T> {
    None,
    One(T),
    Two([T; 2]),
    Three([T; 3]),
    Vec(Vec<T>),
}

Variants§

§

None

§

One(T)

§

Two([T; 2])

§

Three([T; 3])

§

Vec(Vec<T>)

Implementations§

source§

impl<T> OptVec<T>

source

pub fn new() -> OptVec<T>

source

pub fn with_capacity(sz: usize) -> OptVec<T>

source

pub fn take(&mut self) -> OptVec<T>

source

pub fn len(&self) -> usize

source

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

source

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

source

pub fn get(&self, i: usize) -> Option<&T>

source

pub fn get_mut(&mut self, i: usize) -> Option<&mut T>

source

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

source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

source

pub fn for_each<F: FnMut(&T)>(&self, f: F)

source

pub fn consume<F: FnMut(T)>(&mut self, f: F)

source

pub fn map<Q, F>(self, func: F) -> OptVec<Q>
where F: Fn(T) -> Q,

Trait Implementations§

source§

impl<T: Clone> Clone for OptVec<T>

source§

fn clone(&self) -> OptVec<T>

Returns a copy 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> Debug for OptVec<T>

source§

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

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

impl<T> Extend<T> for OptVec<T>

source§

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

Extends a collection with the contents of an iterator. Read more
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> From<T> for OptVec<T>

source§

fn from(t: T) -> OptVec<T>

Converts to this type from the input type.
source§

impl<T> From<Vec<T>> for OptVec<T>

source§

fn from(ts: Vec<T>) -> OptVec<T>

Converts to this type from the input type.
source§

impl<T> FromIterator<T> for OptVec<T>

source§

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

Creates a value from an iterator. Read more
source§

impl<T: Hash> Hash for OptVec<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

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

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T> Index<usize> for OptVec<T>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: usize) -> &T

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

impl<T> IndexMut<usize> for OptVec<T>

source§

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

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

impl<T> Into<OptVec<T>> for OptVec10<T>

source§

fn into(self) -> OptVec<T>

Converts this type into the (usually inferred) input type.
source§

impl<'t, T> IntoIterator for &'t OptVec<T>

§

type Item = &'t T

The type of the elements being iterated over.
§

type IntoIter = Iter<'t, T>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'t, T> IntoIterator for &'t mut OptVec<T>

§

type Item = &'t mut T

The type of the elements being iterated over.
§

type IntoIter = IterMut<'t, T>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> IntoIterator for OptVec<T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: Ord> Ord for OptVec<T>

source§

fn cmp(&self, other: &OptVec<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<T: PartialEq> PartialEq for OptVec<T>

source§

fn eq(&self, other: &OptVec<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd> PartialOrd for OptVec<T>

source§

fn partial_cmp(&self, other: &OptVec<T>) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

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

fn le(&self, other: &Rhs) -> bool

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

fn gt(&self, other: &Rhs) -> bool

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

fn ge(&self, other: &Rhs) -> bool

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

impl<T: Eq> Eq for OptVec<T>

source§

impl<T> StructuralEq for OptVec<T>

source§

impl<T> StructuralPartialEq for OptVec<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for OptVec<T>
where T: RefUnwindSafe,

§

impl<T> Send for OptVec<T>
where T: Send,

§

impl<T> Sync for OptVec<T>
where T: Sync,

§

impl<T> Unpin for OptVec<T>
where T: Unpin,

§

impl<T> UnwindSafe for OptVec<T>
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> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.