[][src]Struct oom::NonEmptyVec

pub struct NonEmptyVec<T: Sized> { /* fields omitted */ }

A non-empty vector type, counterpart of Vec<T>.

Implementations

impl<T: Sized> NonEmptyVec<T>[src]

pub fn from_vec(vec: Vec<T>) -> Self[src]

Converts a Vec<T> into a NonEmptyVec.

Panics

This function will panic if passed Vec is empty.

pub fn from_vec_checked(vec: Vec<T>) -> Result<Self, Vec<T>>[src]

Converts a Vec<T> into a NonEmptyVec. Returns passed Vec if it is empty.

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

Returns a raw pointer to the vector's buffer.

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

Returns an unsafe mutable pointer to the vector's buffer.

pub fn as_nonempty_slice(&self) -> NonEmptySlice<'_, T>[src]

Returns a non-empty slice from this vec.

pub fn as_nonempty_mut_slice(&mut self) -> NonEmptyMutSlice<'_, T>[src]

Returns a non-empty mutable slice from this vec.

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

Extracts a slice containing the entire vector.

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

Extracts a mutable slice of the entire vector.

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

Returns the number of elements in the vector.

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

Always returns false because the vector is non-empty.

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

Returns the number of elements the vector can hold without reallocating.

pub fn into_vec(self) -> Vec<T>[src]

Converts self into a vector without clones or allocations.

pub fn to_vec(&self) -> Vec<T> where
    T: Clone
[src]

Copies self into a new Vec.

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

A shorthand for NonEmptyMutSlice::first.

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

A shorthand for NonEmptyMutSlice::first_mut.

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

A shorthand for NonEmptyMutSlice::last.

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

A shorthand for NonEmptyMutSlice::last_mut.

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

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

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

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

Trait Implementations

impl<T> AsRef<[T]> for NonEmptyVec<T>[src]

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

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

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

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

impl<T: PartialOrd> PartialOrd<NonEmptyVec<T>> for NonEmptyVec<T>[src]

Auto Trait Implementations

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

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

impl<T> Unpin for NonEmptyVec<T> 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<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.