Trait Iterator

Source
pub trait Iterator {
    type Item;

    // Required method
    async fn next(&mut self) -> Option<Self::Item>;

    // Provided methods
    fn size_hint(&self) -> (usize, Option<usize>) { ... }
    fn map<B, F>(self, f: F) -> Map<Self, F>
       where Self: Sized,
             F: FnMut(Self::Item) -> B { ... }
    async fn collect<B: FromIterator<Self::Item>>(self) -> B
       where Self: Sized { ... }
    fn lend(self) -> Lend<Self>
       where Self: Sized { ... }
    fn lend_mut(self) -> LendMut<Self>
       where Self: Sized { ... }
}
Expand description

An interface for dealing with iterators.

Required Associated Types§

Source

type Item

The type of the elements being iterated over.

Required Methods§

Source

async fn next(&mut self) -> Option<Self::Item>

Advances the iterator and returns the next value.

Provided Methods§

Source

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the iterator.

Source

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

Takes a closure and creates an iterator which calls that closure on each element.

Source

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

Transforms an iterator into a collection.

Source

fn lend(self) -> Lend<Self>
where Self: Sized,

Creates an iterator which yields a reference to self as well as the next value.

Source

fn lend_mut(self) -> LendMut<Self>
where Self: Sized,

Creates an iterator which yields a mutable reference to self as well as the next value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<I, F, B, Fut> Iterator for Map<I, F>
where I: Iterator, F: FnMut(I::Item) -> Fut, Fut: Future<Output = B>,

Source§

type Item = B