Struct RevSlice

Source
pub struct RevSlice<T>(/* private fields */);
Expand description

A DST newtype providing a reversed view of a slice.

Implementations§

Source§

impl<T> RevSlice<T>

Source

pub fn rev(&self) -> &[T]

Provides a reversed view of the reversed slice, aka the original slice.

Source

pub fn rev_mut(&mut self) -> &mut [T]

Provides a reversed view of the reversed slice, aka the original mutable slice.

Source§

impl<T> RevSlice<T>

These methods work like their equivalents in core.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn first(&self) -> Option<&T>

Source

pub fn first_mut(&mut self) -> Option<&mut T>

Source

pub fn last(&self) -> Option<&T>

Source

pub fn last_mut(&mut self) -> Option<&mut T>

Source

pub fn split_first(&self) -> Option<(&T, &RevSlice<T>)>

Source

pub fn split_first_mut(&mut self) -> Option<(&T, &RevSlice<T>)>

Source

pub fn split_last(&self) -> Option<(&T, &RevSlice<T>)>

Source

pub fn split_last_mut(&mut self) -> Option<(&T, &RevSlice<T>)>

Source

pub fn split_at(&self, mid: usize) -> (&RevSlice<T>, &RevSlice<T>)

Source

pub fn split_at_mut( &mut self, mid: usize, ) -> (&mut RevSlice<T>, &mut RevSlice<T>)

Source§

impl<T> RevSlice<T>

Source

pub fn iter(&self) -> Rev<Iter<'_, T>>

my_slice.rev().iter() and my_slice.iter().rev() are equivalent.

Source

pub fn iter_mut(&mut self) -> Rev<IterMut<'_, T>>

my_slice.rev().iter_mut() and my_slice.iter_mut().rev() are equivalent.

Trait Implementations§

Source§

impl<T: Debug> Debug for RevSlice<T>

Source§

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

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

impl<T> Index<Range<usize>> for RevSlice<T>

Source§

type Output = RevSlice<T>

The returned type after indexing.
Source§

fn index(&self, index: Range<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> Index<usize> for RevSlice<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<Range<usize>> for RevSlice<T>

Source§

fn index_mut(&mut self, index: Range<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<usize> for RevSlice<T>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, T> IntoIterator for &'a RevSlice<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Rev<Iter<'a, T>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T> IntoIterator for &'a mut RevSlice<T>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = Rev<IterMut<'a, T>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: Ord> Ord for RevSlice<T>

Source§

fn cmp(&self, other: &RevSlice<T>) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl<T: PartialEq> PartialEq for RevSlice<T>

Source§

fn eq(&self, other: &RevSlice<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd> PartialOrd for RevSlice<T>

Source§

fn partial_cmp(&self, other: &RevSlice<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Eq> Eq for RevSlice<T>

Source§

impl<T> StructuralPartialEq for RevSlice<T>

Auto Trait Implementations§

§

impl<T> Freeze for RevSlice<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for RevSlice<T>
where T: RefUnwindSafe,

§

impl<T> Send for RevSlice<T>
where T: Send,

§

impl<T> !Sized for RevSlice<T>

§

impl<T> Sync for RevSlice<T>
where T: Sync,

§

impl<T> Unpin for RevSlice<T>
where T: Unpin,

§

impl<T> UnwindSafe for RevSlice<T>
where T: UnwindSafe,

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