pub struct NonEmptyVec<T: Sized> { /* private fields */ }
Expand description
A non-empty vector type, counterpart of Vec<T>
.
Implementations§
Source§impl<T: Sized> NonEmptyVec<T>
impl<T: Sized> NonEmptyVec<T>
Sourcepub fn from_vec_checked(vec: Vec<T>) -> Result<Self, Vec<T>>
pub fn from_vec_checked(vec: Vec<T>) -> Result<Self, Vec<T>>
Converts a Vec<T>
into a NonEmptyVec
.
Returns passed Vec
if it is empty.
Sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Returns an unsafe mutable pointer to the vector’s buffer.
Sourcepub fn as_nonempty_slice(&self) -> NonEmptySlice<'_, T>
pub fn as_nonempty_slice(&self) -> NonEmptySlice<'_, T>
Returns a non-empty slice from this vec.
Sourcepub fn as_nonempty_mut_slice(&mut self) -> NonEmptyMutSlice<'_, T>
pub fn as_nonempty_mut_slice(&mut self) -> NonEmptyMutSlice<'_, T>
Returns a non-empty mutable slice from this vec.
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Extracts a mutable slice of the entire vector.
Sourcepub fn len(&self) -> NonZeroUsize
pub fn len(&self) -> NonZeroUsize
Returns the number of elements in the vector.
Sourcepub fn capacity(&self) -> NonZeroUsize
pub fn capacity(&self) -> NonZeroUsize
Returns the number of elements the vector can hold without reallocating.
Sourcepub fn first(&self) -> &T
pub fn first(&self) -> &T
A shorthand for NonEmptyMutSlice::first
.
Sourcepub fn first_mut(&mut self) -> &mut T
pub fn first_mut(&mut self) -> &mut T
A shorthand for NonEmptyMutSlice::first_mut
.
Sourcepub fn last(&self) -> &T
pub fn last(&self) -> &T
A shorthand for NonEmptyMutSlice::last
.
Sourcepub fn last_mut(&mut self) -> &mut T
pub fn last_mut(&mut self) -> &mut T
A shorthand for NonEmptyMutSlice::last_mut
.
Sourcepub fn split_first(&self) -> (&T, &[T])
pub fn split_first(&self) -> (&T, &[T])
A shorthand for NonEmptyMutSlice::split_first
.
Sourcepub fn split_first_mut(&mut self) -> (&mut T, &mut [T])
pub fn split_first_mut(&mut self) -> (&mut T, &mut [T])
A shorthand for NonEmptyMutSlice::split_first_mut
.
Sourcepub fn split_last(&self) -> (&T, &[T])
pub fn split_last(&self) -> (&T, &[T])
A shorthand for NonEmptyMutSlice::split_last
.
Sourcepub fn split_last_mut(&mut self) -> (&mut T, &mut [T])
pub fn split_last_mut(&mut self) -> (&mut T, &mut [T])
A shorthand for NonEmptyMutSlice::split_last_mut
.