[][src]Struct non_empty_vec::NonEmpty

pub struct NonEmpty<T>(_);

Non empty vector, ensure non empty by construction. Inherits Vec's methods through Deref trait, not implement DerefMut. Overridden these methods:

  • len returns NonZeroUsize and is_empty always returns false.
  • first(_mut), last(_mut), split_first(_mut), split_last(_mut) don't return Option.
  • pop returns None if there is only one element in it.

Implementations

impl<T> NonEmpty<T>[src]

pub fn new(vec: Vec<T>) -> Option<NonEmpty<T>>[src]

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

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

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

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

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

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

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

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

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

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

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]

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

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

Trait Implementations

impl<T> AsMut<[T]> for NonEmpty<T>[src]

impl<T> AsMut<Vec<T>> for NonEmpty<T>[src]

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

impl<T> AsRef<Vec<T>> for NonEmpty<T>[src]

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

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

impl<T> Deref for NonEmpty<T>[src]

type Target = [T]

The resulting type after dereferencing.

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

impl<T> From<(T, Vec<T>)> for NonEmpty<T>[src]

impl<T> From<(Vec<T>, T)> for NonEmpty<T>[src]

impl<T, I: SliceIndex<[T]>> Index<I> for NonEmpty<T>[src]

type Output = I::Output

The returned type after indexing.

impl<T, I: SliceIndex<[T]>> IndexMut<I> for NonEmpty<T>[src]

impl<T> Into<Vec<T>> for NonEmpty<T>[src]

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

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

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

impl<T> StructuralEq for NonEmpty<T>[src]

impl<T> StructuralPartialEq for NonEmpty<T>[src]

impl<T> TryFrom<Vec<T>> for NonEmpty<T>[src]

type Error = EmptyError

The type returned in the event of a conversion error.

Auto Trait Implementations

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

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

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

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

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

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.