pub struct Last;🔬This is a nightly-only experimental API. (
sliceindex_wrappers)Expand description
Always accesses the last element of the slice.
§Examples
#![feature(sliceindex_wrappers)]
#![feature(slice_index_methods)]
use core::index::Last;
use core::slice::SliceIndex;
let s = &[0, 1, 2, 3];
assert_eq!(&3, &s[Last]);
assert_eq!(None, Last.get(&[] as &[usize]));
Trait Implementations§
Source§impl<T> SliceIndex<[T]> for Last
impl<T> SliceIndex<[T]> for Last
Source§fn get(self, slice: &[T]) -> Option<&<Last as SliceIndex<[T]>>::Output>
fn get(self, slice: &[T]) -> Option<&<Last as SliceIndex<[T]>>::Output>
🔬This is a nightly-only experimental API. (
slice_index_methods)Returns a shared reference to the output at this location, if in
bounds.
Source§fn get_mut(
self,
slice: &mut [T],
) -> Option<&mut <Last as SliceIndex<[T]>>::Output>
fn get_mut( self, slice: &mut [T], ) -> Option<&mut <Last as SliceIndex<[T]>>::Output>
🔬This is a nightly-only experimental API. (
slice_index_methods)Returns a mutable reference to the output at this location, if in
bounds.
Source§unsafe fn get_unchecked(
self,
slice: *const [T],
) -> *const <Last as SliceIndex<[T]>>::Output
unsafe fn get_unchecked( self, slice: *const [T], ) -> *const <Last as SliceIndex<[T]>>::Output
🔬This is a nightly-only experimental API. (
slice_index_methods)Returns a pointer to the output at this location, without
performing any bounds checking. Read more
Source§unsafe fn get_unchecked_mut(
self,
slice: *mut [T],
) -> *mut <Last as SliceIndex<[T]>>::Output
unsafe fn get_unchecked_mut( self, slice: *mut [T], ) -> *mut <Last as SliceIndex<[T]>>::Output
🔬This is a nightly-only experimental API. (
slice_index_methods)Returns a mutable pointer to the output at this location, without
performing any bounds checking. Read more
Auto Trait Implementations§
impl Freeze for Last
impl RefUnwindSafe for Last
impl Send for Last
impl Sync for Last
impl Unpin for Last
impl UnwindSafe for Last
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more