[−][src]Struct oom::NonEmptyMutSlice
An non-empty mutable slice type, counterpart of &mut [T]
.
Implementations
impl<'a, T: Sized> NonEmptyMutSlice<'a, T>
[src]
pub fn from_mut(e: &'a mut T) -> Self
[src]
Converts a &T
into a NonEmptyMutSlice
.
pub fn from_slice(slice: &'a mut [T]) -> Self
[src]
Converts a &[T]
into a NonEmptyMutSlice
.
Panics
This function will panic if the passed slice is empty.
pub fn from_slice_checked(slice: &'a mut [T]) -> Option<Self>
[src]
Converts a &[T]
into a NonEmptyMutSlice
.
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_mut_ptr(&self) -> *mut T
[src]
Returns an unsafe mutable pointer to the slice's buffer.
The caller must ensure that the slice outlives the pointer this function returns, or else it will end up pointing to garbage.
pub fn as_slice(&self) -> &'a [T]
[src]
Returns a &[T]
containing entire NonEmptyMutSlice
.
pub fn as_mut_slice(&self) -> &'a mut [T]
[src]
Returns a mutable slice from this type.
pub fn len(&self) -> NonZeroUsize
[src]
Returns the number of elements in the slice.
pub fn is_empty(&self) -> bool
[src]
Always returns false
because the slice is non-empty.
pub fn first(&self) -> &'a T
[src]
Returns the first element of the slice.
let arr = &mut [10, 40, 30]; let s = NonEmptyMutSlice::from_slice(arr); assert_eq!(s.first(), &10);
pub fn first_mut(&mut self) -> &'a mut T
[src]
Returns a mutable pointer to the first element of the slice.
let arr = &mut [10, 40, 30]; let mut s = NonEmptyMutSlice::from_slice(arr); *s.first_mut() = 42; assert_eq!(arr, &[42, 40, 30]);
pub fn last(&self) -> &'a T
[src]
Returns the last element of the slice.
let arr = &mut [10, 40, 30]; let s = NonEmptyMutSlice::from_slice(arr); assert_eq!(s.last(), &30);
pub fn last_mut(&mut self) -> &'a mut T
[src]
Returns the last element of the slice.
let arr = &mut [10, 40, 30]; let mut s = NonEmptyMutSlice::from_slice(arr); *s.last_mut() = 42; assert_eq!(arr, &[10, 40, 42]);
pub fn split_first(&self) -> (&'a T, &'a [T])
[src]
Returns the first and all the rest of the elements of the slice.
let arr = &mut [10, 40, 30]; let s = NonEmptyMutSlice::from_slice(arr); assert_eq!(s.split_first(), (&10, &[40, 30][..]));
pub fn split_first_mut(&mut self) -> (&'a mut T, &'a mut [T])
[src]
Returns the first and all the rest of the elements of the slice.
let arr = &mut [0, 1, 2]; let mut s = NonEmptyMutSlice::from_slice(arr); let (first, rest) = s.split_first_mut(); *first = 3; rest[0] = 4; rest[1] = 5; assert_eq!(arr, &[3, 4, 5]);
pub fn split_last(&self) -> (&'a T, &'a [T])
[src]
Returns the last and all the rest of the elements of the slice.
let arr = &mut [10, 40, 30]; let s = NonEmptyMutSlice::from_slice(arr); assert_eq!(s.split_last(), (&30, &[10, 40][..]));
pub fn split_last_mut(&mut self) -> (&'a mut T, &'a mut [T])
[src]
Returns the last and all the rest of the elements of the slice.
let arr = &mut [0, 1, 2]; let mut s = NonEmptyMutSlice::from_slice(arr); let (last, rest) = s.split_last_mut(); *last = 3; rest[0] = 4; rest[1] = 5; assert_eq!(arr, &[4, 5, 3]);
Trait Implementations
impl<'a, T> AsRef<[T]> for NonEmptyMutSlice<'a, T>
[src]
impl<'a, T: Clone> Clone for NonEmptyMutSlice<'a, T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, T: Eq> Eq for NonEmptyMutSlice<'a, T>
[src]
impl<'a, T: Ord> Ord for NonEmptyMutSlice<'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<NonEmptyMutSlice<'a, T>> for NonEmptyMutSlice<'a, T>
[src]
impl<'a, T: PartialOrd> PartialOrd<NonEmptyMutSlice<'a, T>> for NonEmptyMutSlice<'a, T>
[src]
Auto Trait Implementations
impl<'a, T> !Send for NonEmptyMutSlice<'a, T>
impl<'a, T> !Sync for NonEmptyMutSlice<'a, T>
impl<'a, T> Unpin for NonEmptyMutSlice<'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, 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>,