#parallel #iterator

rayon-cond

Experimental iterator wrapper that is conditionally parallel or serial

2 unstable releases

0.2.0 May 21, 2021
0.1.0 Feb 22, 2019

#87 in Concurrency

Download history 209/week @ 2021-04-03 305/week @ 2021-04-10 255/week @ 2021-04-17 357/week @ 2021-04-24 123/week @ 2021-05-01 450/week @ 2021-05-08 411/week @ 2021-05-15 233/week @ 2021-05-22 142/week @ 2021-05-29 125/week @ 2021-06-05 154/week @ 2021-06-12 120/week @ 2021-06-19 167/week @ 2021-06-26 127/week @ 2021-07-03 136/week @ 2021-07-10 159/week @ 2021-07-17

1,363 downloads per month
Used in 5 crates (2 directly)

Apache-2.0/MIT

27KB
733 lines

rayon-cond

Crate Documentation minimum rustc 1.38 Build Status

Experimental iterator wrapper that is conditionally parallel or serial, using Rayon's ParallelIterator or the standard Iterator respectively.

Usage

First add this crate to your Cargo.toml:

[dependencies]
rayon-cond = "0.2"

Then in your code, it may be used something like this:

use rayon_cond::CondIterator;

fn main() {
    let args: Vec<_> = std::env::args().collect();

    // Run in parallel if there are an even number of args
    let par = args.len() % 2 == 0;

    CondIterator::new(args, par).enumerate().for_each(|(i, arg)| {
        println!("arg {}: {:?}", i, arg);
    });
}

rayon-cond currently requires rustc 1.38.0 or greater.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.5MB
~33K SLoC