Struct odds::slice::rev::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]

[src]

Return the length of the slice.

[src]

Get element at index i.

See also indexing notation: &foo[i].

[src]

Get element at index i.

See also indexing notation: &mut foo[i].

[src]

[src]

[src]

[src]

Return a by-reference iterator

[src]

Return a by-mutable-reference iterator

[src]

[src]

Trait Implementations

impl<T: Debug> Debug for RevSlice<T>
[src]

[src]

Formats the value using the given formatter.

impl<T: Eq> Eq for RevSlice<T>
[src]

impl<T, U> PartialEq<RevSlice<U>> for RevSlice<T> where
    T: PartialEq<U>, 
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl<T, U> PartialEq<[U]> for RevSlice<T> where
    T: PartialEq<U>, 
[src]

RevSlice compares by logical element sequence.

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl<T> Hash for RevSlice<T> where
    T: Hash
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

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]

[src]

Performs the conversion.

impl<'a, T, Slice: ?Sized> From<&'a mut Slice> for &'a mut RevSlice<T> where
    Slice: AsMut<[T]>, 
[src]

[src]

Performs the conversion.

impl<T> Index<usize> for RevSlice<T>
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<T> IndexMut<usize> for RevSlice<T>
[src]

[src]

Performs the mutable indexing (container[index]) operation.

impl<'a, T> Default for &'a RevSlice<T>
[src]

[src]

Returns the "default value" for a type. Read more

impl<'a, T> Default for &'a mut RevSlice<T>
[src]

[src]

Returns the "default value" for a type. Read more

impl<T, R> Index<R> for RevSlice<T> where
    R: IndexRange
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<T, R> IndexMut<R> for RevSlice<T> where
    R: IndexRange
[src]

[src]

Performs the mutable indexing (container[index]) operation.

impl<'a, T> IntoIterator for &'a RevSlice<T>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl<T> SliceFind for RevSlice<T>
[src]

[src]

Linear search for the first occurrence elt in the slice. Read more

[src]

Linear search for the last occurrence elt in the slice. Read more