[][src]Struct odds::stride::Stride

pub struct Stride<'a, A: 'a> { /* fields omitted */ }

(the stride) skipped per iteration.

Stride does not support zero-sized types for A.

Iterator element type is &'a A.

Methods

impl<'a, A> Stride<'a, A>[src]

pub unsafe fn from_ptr_len(
    begin: *const A,
    nelem: usize,
    stride: isize
) -> Stride<'a, A>
[src]

Create a Stride iterator from a raw pointer.

impl<'a, A> Stride<'a, A>[src]

pub fn from_slice(xs: &'a [A], step: isize) -> Stride<'a, A>[src]

Create Stride iterator from a slice and the element step count.

If step is negative, start from the back.

use odds::stride::Stride;

let xs = [0, 1, 2, 3, 4, 5];

let front = Stride::from_slice(&xs, 2);
assert_eq!(front[0], 0);
assert_eq!(front[1], 2);

let back = Stride::from_slice(&xs, -2);
assert_eq!(back[0], 5);
assert_eq!(back[1], 3);

Panics if values of type A are zero-sized.
Panics if step is 0.

pub fn from_stride(it: Stride<'a, A>, step: isize) -> Stride<'a, A>[src]

Create Stride iterator from an existing Stride iterator

Panics if step is 0.

pub fn swap_ends(&mut self)[src]

Swap the begin and end and reverse the stride, in effect reversing the iterator.

pub fn len(&self) -> usize[src]

Return the number of elements in the iterator.

pub fn get<'b>(&'b self, i: usize) -> Option<&'b A>[src]

Return a reference to the element of a stride at the given index, or None if the index is out of bounds.

Trait Implementations

impl<'a, A> Clone for Stride<'a, A>[src]

impl<'a, A> Copy for Stride<'a, A>[src]

impl<'a, A> Debug for Stride<'a, A> where
    A: Debug
[src]

impl<'a, A> DoubleEndedIterator for Stride<'a, A>[src]

impl<'a, A> ExactSizeIterator for Stride<'a, A>[src]

impl<'a, A> Index<usize> for Stride<'a, A>[src]

type Output = A

The returned type after indexing.

fn index<'b>(&'b self, i: usize) -> &'b A[src]

Return a reference to the element at a given index.

Panics if the index is out of bounds.

impl<'a, A> Iterator for Stride<'a, A>[src]

type Item = &'a A

The type of the elements being iterated over.

impl<'a, A> Send for Stride<'a, A> where
    A: Sync
[src]

impl<'a, A> Sync for Stride<'a, A> where
    A: Sync
[src]

Auto Trait Implementations

impl<'a, A> RefUnwindSafe for Stride<'a, A> where
    A: RefUnwindSafe

impl<'a, A> Unpin for Stride<'a, A>

impl<'a, A> UnwindSafe for Stride<'a, A> where
    A: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.