Trait Iterate

Source
pub trait Iterate {
    type Item;
    type Iterator: Iterator<Item = Self::Item>;

    // Required method
    fn iterate(self) -> Self::Iterator;

    // Provided methods
    fn map<F, B>(self, f: F) -> IntoMap<Self, F>
       where F: FnOnce(Self::Item) -> B,
             Self: Sized { ... }
    fn collect<B: Collect<Self::Item>>(self) -> B
       where Self: Sized { ... }
}
Expand description

Provide sequential, iterated access to items.

Required Associated Types§

Source

type Item

The type of the elements being iterated over.

Source

type Iterator: Iterator<Item = Self::Item>

Which kind of iterator are we turning this into?

Required Methods§

Source

fn iterate(self) -> Self::Iterator

Begin iteration and obtain a stateful Iterator.

Provided Methods§

Source

fn map<F, B>(self, f: F) -> IntoMap<Self, F>
where F: FnOnce(Self::Item) -> B, Self: Sized,

Maps the values of iter with f.

Source

fn collect<B: Collect<Self::Item>>(self) -> B
where Self: Sized,

Transforms this iterator into a collection.

Implementors§

Source§

impl<B, I: Iterate, F> Iterate for IntoMap<I, F>
where F: FnMut(I::Item) -> B,

Source§

type Item = B

Source§

type Iterator = Map<<I as Iterate>::Iterator, F>

Source§

impl<T> Iterate for T
where T: Iterator,