Struct Last

pub struct Last;

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

impl Debug for Last

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<T> SliceIndex<[T]> for Last

type Output = T;
fn get(self, slice: &[T]) -> Option<&Self::Output>
fn get_mut(self, slice: &mut [T]) -> Option<&mut Self::Output>
unsafe fn get_unchecked(self, slice: *const [T]) -> *const Self::Output
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut Self::Output
fn index(self, slice: &[T]) -> &Self::Output
fn index_mut(self, slice: &mut [T]) -> &mut Self::Output

Auto Trait Implementations

impl Freeze for Last

impl RefUnwindSafe for Last

impl Send for Last

impl Sync for Last

impl Unpin for Last

impl UnsafeUnpin for Last

impl UnwindSafe for Last

Blanket Implementations

impl<T> Any for Last where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Last where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Last where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for Last

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for Last where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for Last

impl<T, U> Into<U> for Last where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Last where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Last where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>