[−][src]Struct non_empty_vec::NonEmpty
Non empty vector, ensure non empty by construction.
Inherits Vec
's methods through Deref
trait, not implement DerefMut
.
Overridden these methods:
len
returnsNonZeroUsize
andis_empty
always returnsfalse
.first(_mut)
,last(_mut)
,split_first(_mut)
,split_last(_mut)
don't returnOption
.pop
returnsNone
if there is only one element in it.
Methods
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]
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]
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.
fn index(&self, index: I) -> &Self::Output
[src]
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]
fn cmp(&self, other: &NonEmpty<T>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq> PartialEq<NonEmpty<T>> for NonEmpty<T>
[src]
impl<T: PartialOrd> PartialOrd<NonEmpty<T>> for NonEmpty<T>
[src]
fn partial_cmp(&self, other: &NonEmpty<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &NonEmpty<T>) -> bool
[src]
fn le(&self, other: &NonEmpty<T>) -> bool
[src]
fn gt(&self, other: &NonEmpty<T>) -> bool
[src]
fn ge(&self, other: &NonEmpty<T>) -> bool
[src]
impl<T> StructuralEq for NonEmpty<T>
[src]
impl<T> StructuralPartialEq for NonEmpty<T>
[src]
impl<T> TryFrom<Vec<T>> for NonEmpty<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for NonEmpty<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for NonEmpty<T> where
T: Send,
T: Send,
impl<T> Sync for NonEmpty<T> where
T: Sync,
T: Sync,
impl<T> Unpin for NonEmpty<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for NonEmpty<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,