Trait ParallelBridge
trait ParallelBridge: Sized
Conversion trait to convert an Iterator to a ParallelIterator.
This creates a "bridge" from a sequential iterator to a parallel one, by distributing its items
across the Rayon thread pool. This has the advantage of being able to parallelize just about
anything, but the resulting ParallelIterator can be less efficient than if you started with
par_iter instead. However, it can still be useful for iterators that are difficult to
parallelize by other means, like channels or file or network I/O.
Iterator items are pulled by next() one at a time, synchronized from each thread that is
ready for work, so this may become a bottleneck if the serial iterator can't keep up with the
parallel demand. The items are not buffered by IterBridge, so it's fine to use this with
large or even unbounded iterators.
The resulting iterator is not guaranteed to keep the order of the original iterator.
Examples
To use this trait, take an existing Iterator and call par_bridge on it. After that, you can
use any of the ParallelIterator methods:
use ParallelBridge;
use ParallelIterator;
use channel;
let rx = ;
let mut output: = rx.into_iter.par_bridge.collect;
output.sort_unstable;
assert_eq!;
Required Methods
fn par_bridge(self: Self) -> IterBridge<Self>Creates a bridge from this type to a
ParallelIterator.
Implementors
impl<T: Iterator + Send> ParallelBridge for T