[][src]Struct oom::NonEmptySlice

pub struct NonEmptySlice<'a, T: Sized> { /* fields omitted */ }

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]

Converts a &[T] into a NonEmptySlice.

Panics

This function will panic if the passed slice is empty.

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]

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]

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

impl<'a, T> Sync for NonEmptySlice<'a, T> where
    T: Sync

impl<'a, T> Unpin for NonEmptySlice<'a, T>

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.