Last

Struct Last 

Source
pub struct Last;
🔬This is a nightly-only experimental API. (sliceindex_wrappers #146179)
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 Debug for Last

Source§

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

Formats the value using the given formatter. Read more
Source§

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

Source§

type Output = T

The output type returned by methods.
Source§

fn get(self, slice: &[T]) -> Option<&Self::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 Self::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 Self::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 Self::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
Source§

fn index(self, slice: &[T]) -> &Self::Output

🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a shared reference to the output at this location, panicking if out of bounds.
Source§

fn index_mut(self, slice: &mut [T]) -> &mut Self::Output

🔬This is a nightly-only experimental API. (slice_index_methods)
Returns a mutable reference to the output at this location, panicking if out of bounds.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.