Trait ForEach

Source
pub trait ForEach: Iterator {
    // Required method
    fn foreach<O, F>(&mut self, f: F)
       where O: Into<Continue>,
             F: FnMut(Self::Item, &mut Self) -> O;
}
Expand description

Trait to simplify usage of iterator inside iteration loop.

This trait is implemented for all iterators by default.

Required Methods§

Source

fn foreach<O, F>(&mut self, f: F)
where O: Into<Continue>, F: FnMut(Self::Item, &mut Self) -> O,

Iterates over all items and executes given closure.

This allows you to use iterator inside iteration loop, which is not posible when using for-in loop.

See crate-level docs for examples

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<T: Iterator> ForEach for T