Skip to main content

MaybeParIter

Trait MaybeParIter 

Source
pub trait MaybeParIter {
    type Item;
    type ParIter: ParallelIterator<Item = Self::Item>;
    type Iter: Iterator<Item = Self::Item>;

    // Required method
    fn maybe_par_iter(
        self,
        parallel: bool,
    ) -> MaybeParallel<Self::ParIter, Self::Iter>;
}
Expand description

Trait which allows use of Rayon parallelism to be conditionally enabled.

See https://crates.io/crates/rayon-cond for a more full-featured alternative.

Required Associated Types§

Source

type Item

Source

type ParIter: ParallelIterator<Item = Self::Item>

Source

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

Required Methods§

Source

fn maybe_par_iter( self, parallel: bool, ) -> MaybeParallel<Self::ParIter, Self::Iter>

Return an iterator which executes either in serial on the current thread, or in parallel in a Rayon thread pool if parallel is true.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<Item, I: IntoParallelIterator<Item = Item> + IntoIterator<Item = Item>> MaybeParIter for I