Function for_each

Source
pub fn for_each<I, F, T>(i: I, f: F)
where I: Iterator<Item = T>, F: Fn(T) + Sync, T: Send,
Expand description

Calls the closure on each element of the iterator in parallel, waiting for all closures to finish.

  • The closure does not require 'static lifetime since the for_each function bounds the lifetime of all submitted closures.
  • The closure must be Sync as multiple threads will refer to it.
  • The iterator items must be Send as they will be sent from one thread to another.