Struct Last

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]));

Implementations

impl Debug for Last

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

impl Freeze for Last

impl RefUnwindSafe for Last

impl Send for Last

impl Sync for Last

impl Unpin for Last

impl UnwindSafe for Last

impl<T> Any for Last

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Last

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Last

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

impl<T> From for Last

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SliceIndex for Last

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

impl<T, U> Into for Last

fn into(self: 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 for Last

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Last

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