Trait nonempty_collections::array::NonEmptyArrayExt
source · pub trait NonEmptyArrayExt<T> {
// Required methods
fn as_nonempty_slice(&self) -> NESlice<'_, T>;
fn nonzero_len(&self) -> NonZeroUsize;
fn into_nonempty_vec(self) -> NEVec<T>;
}
Expand description
Provides extension methods for non-empty arrays.
§Examples
Create a non-empty slice of an array:
assert_eq!(NESlice::new(&1, &[2]), [1, 2].as_nonempty_slice());
Get the length of an array as a NonZeroUsize
:
assert_eq!(NonZeroUsize::MIN, [1].nonzero_len());
Convert array into a non-empty vec:
assert_eq!(nev![4], [4].into_nonempty_vec());
Required Methods§
sourcefn as_nonempty_slice(&self) -> NESlice<'_, T>
fn as_nonempty_slice(&self) -> NESlice<'_, T>
Create a NESlice
that borrows the contents of self
.
sourcefn nonzero_len(&self) -> NonZeroUsize
fn nonzero_len(&self) -> NonZeroUsize
Returns the length of this array as a NonZeroUsize
.
sourcefn into_nonempty_vec(self) -> NEVec<T>
fn into_nonempty_vec(self) -> NEVec<T>
Moves self
into a new crate::NEVec
.