[−][src]Struct odds::slice::rev::RevSlice
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]
pub fn len(&self) -> usize
[src]
Return the length of the slice.
pub fn get(&self, i: usize) -> Option<&T>
[src]
Get element at index i
.
See also indexing notation: &foo[i]
.
pub fn get_mut(&mut self, i: usize) -> Option<&mut T>
[src]
Get element at index i
.
See also indexing notation: &mut foo[i]
.
pub fn inner_ref(&self) -> &[T]
[src]
pub fn inner_mut(&mut self) -> &mut [T]
[src]
pub fn into_boxed_slice(self: Box<Self>) -> Box<[T]>
[src]
pub fn iter(&self) -> Rev<Iter<T>>
[src]
Return a by-reference iterator
pub fn iter_mut(&mut self) -> Rev<IterMut<T>>
[src]
Return a by-mutable-reference iterator
pub fn split_at(&self, i: usize) -> (&Self, &Self)
[src]
pub fn split_at_mut(&mut self, i: usize) -> (&mut Self, &mut Self)
[src]
Trait Implementations
impl<T: Debug> Debug for RevSlice<T>
[src]
impl<'a, T> Default for &'a RevSlice<T>
[src]
impl<'a, T> Default for &'a mut RevSlice<T>
[src]
impl<T: Eq> Eq for RevSlice<T>
[src]
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> Hash for RevSlice<T> where
T: Hash,
[src]
T: Hash,
fn hash<H: Hasher>(&self, h: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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]
impl<T> Index<usize> for RevSlice<T>
[src]
impl<T, R> IndexMut<R> for RevSlice<T> where
R: IndexRange,
[src]
R: IndexRange,
impl<T> IndexMut<usize> for RevSlice<T>
[src]
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]
impl<'a, T> IntoIterator for &'a mut RevSlice<T>
[src]
type Item = &'a mut T
The type of the elements being iterated over.
type IntoIter = Rev<IterMut<'a, T>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<T, U> PartialEq<[U]> for RevSlice<T> where
T: PartialEq<U>,
[src]
T: PartialEq<U>,
RevSlice
compares by logical element sequence.
impl<T, U> PartialEq<RevSlice<U>> for RevSlice<T> where
T: PartialEq<U>,
[src]
T: PartialEq<U>,
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>,
fn rfind<U: ?Sized>(&self, elt: &U) -> Option<usize> where
Self::Item: PartialEq<U>,
[src]
Self::Item: PartialEq<U>,
impl<T> StructuralEq for RevSlice<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for RevSlice<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for RevSlice<T> where
T: Send,
T: Send,
impl<T> Sync for RevSlice<T> where
T: Sync,
T: Sync,
impl<T> Unpin for RevSlice<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for RevSlice<T> where
T: UnwindSafe,
T: UnwindSafe,