[−][src]Struct oom::NonEmptySlice
A non-empty slice type, counterpart of &[T]
.
Implementations
impl<'a, T: Sized> NonEmptySlice<'a, T>
[src]
pub fn from_ref(e: &'a T) -> Self
[src]
Converts a &T
into a NonEmptySlice
.
pub fn from_slice(slice: &'a [T]) -> Self
[src]
pub const fn from_slice_checked(slice: &'a [T]) -> Option<Self>
[src]
Converts a &[T]
into a NonEmptySlice
.
Returns None
if the passed slice is empty.
pub fn as_ptr(&self) -> *const T
[src]
Returns a raw pointer to the slice's buffer.
pub fn as_slice(&self) -> &[T]
[src]
Returns a &[T]
containing entire NonEmptySlice
.
pub const fn len(&self) -> NonZeroUsize
[src]
Returns the number of elements in the slice.
pub const fn is_empty(&self) -> bool
[src]
Always returns false
because the slice is non-empty.
pub fn first(&self) -> &T
[src]
Returns the first element of the slice.
let s = NonEmptySlice::from_slice(&[10, 40, 30]); assert_eq!(s.first(), &10);
pub fn last(&self) -> &T
[src]
Returns the last element of the slice.
let s = NonEmptySlice::from_slice(&[10, 40, 30]); assert_eq!(s.last(), &30);
pub fn split_first(&self) -> (&T, &[T])
[src]
Returns the first and all the rest of the elements of the slice.
let s = NonEmptySlice::from_slice(&[10, 40, 30]); assert_eq!(s.split_first(), (&10, &[40, 30][..]));
pub fn split_last(&self) -> (&T, &[T])
[src]
Returns the last and all the rest of the elements of the slice.
let s = NonEmptySlice::from_slice(&[10, 40, 30]); assert_eq!(s.split_last(), (&30, &[10, 40][..]));
Trait Implementations
impl<'a, T> AsRef<[T]> for NonEmptySlice<'a, T>
[src]
impl<'a, T: Clone> Clone for NonEmptySlice<'a, T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, T: Copy> Copy for NonEmptySlice<'a, T>
[src]
impl<'a, T: Eq> Eq for NonEmptySlice<'a, T>
[src]
impl<'a, T: Ord> Ord for NonEmptySlice<'a, T>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a, T: PartialEq> PartialEq<NonEmptySlice<'a, T>> for NonEmptySlice<'a, T>
[src]
impl<'a, T: PartialOrd> PartialOrd<NonEmptySlice<'a, T>> for NonEmptySlice<'a, T>
[src]
Auto Trait Implementations
impl<'a, T> Send for NonEmptySlice<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Sync for NonEmptySlice<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Unpin for NonEmptySlice<'a, T>
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 = Infallible
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>,