[][src]Struct iterators_rfoxmich::Counter

pub struct Counter { /* fields omitted */ }

Provides a counter that behaves like an iterator only counting to 5 before it is fully consumed.

Methods

impl Counter[src]

Important traits for Counter
pub fn new() -> Counter[src]

Constructs a new Counter object.

Examples

 use iterators::Counter;
 let c = Counter::new();
 

Trait Implementations

impl Iterator for Counter[src]

type Item = u32

The type of the elements being iterated over.

fn next(&mut self) -> Option<Self::Item>[src]

Returns the next value from a Counter

Examples


use iterators::Counter;
let mut a = Counter::new();

let value = match a.next() {
  Some(i) => i,
  None => 5
};
assert_eq!(value, 1);

Note that this code 'pegs' the iterator at 5 once it's consumed

Auto Trait Implementations

impl RefUnwindSafe for Counter

impl Send for Counter

impl Sync for Counter

impl Unpin for Counter

impl UnwindSafe for Counter

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, 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.