Struct odds::slice::RevSlice
[−]
[src]
#[repr(C)]pub struct RevSlice<T>(_);
A reversed view of a slice.
The RevSlice is a random accessible range of elements;
it wraps a regular slice but presents the underlying elements in
reverse order.
Example
use odds::slice::RevSlice; let mut data = [0; 8]; { let mut rev = <&mut RevSlice<_>>::from(&mut data); for (i, elt) in rev.iter_mut().enumerate() { *elt = i; } assert_eq!(&rev[..4], &[0, 1, 2, 3][..]); } assert_eq!(&data, &[7, 6, 5, 4, 3, 2, 1, 0]);
Not visible in rustdoc:
- A boxed slice can be reversed too:
impl<T> From<Box<[T]>> for Box<RevSlice<T>>.
Methods
impl<T> RevSlice<T>[src]
fn len(&self) -> usize[src]
Return the length of the slice.
fn get(&self, i: usize) -> Option<&T>[src]
Get element at index i.
See also indexing notation: &foo[i].
fn get_mut(&mut self, i: usize) -> Option<&mut T>[src]
Get element at index i.
See also indexing notation: &mut foo[i].
fn inner_ref(&self) -> &[T][src]
fn inner_mut(&mut self) -> &mut [T][src]
fn iter(&self) -> Rev<Iter<T>>[src]
Return a by-reference iterator
fn iter_mut(&mut self) -> Rev<IterMut<T>>[src]
Return a by-mutable-reference iterator
fn split_at(&self, i: usize) -> (&Self, &Self)[src]
fn split_at_mut(&mut self, i: usize) -> (&mut Self, &mut Self)[src]
Trait Implementations
impl<T> SliceFind for RevSlice<T>[src]
type Item = T
fn find<U: ?Sized>(&self, elt: &U) -> Option<usize> where
Self::Item: PartialEq<U>, [src]
Self::Item: PartialEq<U>,
Linear search for the first occurrence elt in the slice. Read more
fn rfind<U: ?Sized>(&self, elt: &U) -> Option<usize> where
Self::Item: PartialEq<U>, [src]
Self::Item: PartialEq<U>,
Linear search for the last occurrence elt in the slice. Read more
impl<T: Debug> Debug for RevSlice<T>[src]
impl<T: Eq> Eq for RevSlice<T>[src]
impl<T, U> PartialEq<RevSlice<U>> for RevSlice<T> where
T: PartialEq<U>, [src]
T: PartialEq<U>,
fn eq(&self, rhs: &RevSlice<U>) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl<T, U> PartialEq<[U]> for RevSlice<T> where
T: PartialEq<U>, [src]
T: PartialEq<U>,
RevSlice compares by logical element sequence.
fn eq(&self, rhs: &[U]) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl<T> Hash for RevSlice<T> where
T: Hash, [src]
T: Hash,
fn hash<H: Hasher>(&self, h: &mut H)[src]
Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more
impl<'a, T, Slice: ?Sized> From<&'a Slice> for &'a RevSlice<T> where
Slice: AsRef<[T]>, [src]
Slice: AsRef<[T]>,
impl<'a, T, Slice: ?Sized> From<&'a mut Slice> for &'a mut RevSlice<T> where
Slice: AsMut<[T]>, [src]
Slice: AsMut<[T]>,
impl<T> Index<usize> for RevSlice<T>[src]
type Output = T
The returned type after indexing.
fn index(&self, i: usize) -> &T[src]
Performs the indexing (container[index]) operation.
impl<T> IndexMut<usize> for RevSlice<T>[src]
fn index_mut(&mut self, i: usize) -> &mut T[src]
Performs the mutable indexing (container[index]) operation.
impl<'a, T> Default for &'a RevSlice<T>[src]
impl<'a, T> Default for &'a mut RevSlice<T>[src]
impl<T, R> Index<R> for RevSlice<T> where
R: IndexRange, [src]
R: IndexRange,
type Output = RevSlice<T>
The returned type after indexing.
fn index(&self, index: R) -> &RevSlice<T>[src]
Performs the indexing (container[index]) operation.
impl<T, R> IndexMut<R> for RevSlice<T> where
R: IndexRange, [src]
R: IndexRange,
fn index_mut(&mut self, index: R) -> &mut RevSlice<T>[src]
Performs the mutable indexing (container[index]) operation.
impl<'a, T> IntoIterator for &'a RevSlice<T>[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Rev<Iter<'a, T>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter[src]
Creates an iterator from a value. Read more