| Crates.io | maybe_parallel_iterator |
| lib.rs | maybe_parallel_iterator |
| version | 0.12.0 |
| created_at | 2022-05-27 04:44:49.235915+00 |
| updated_at | 2022-06-27 02:47:52.158339+00 |
| description | Toggle parallelism with feature flags! |
| homepage | |
| repository | https://github.com/finnbear/maybe_parallel_iterator/ |
| max_upload_size | |
| id | 594844 |
| size | 17,905 |
Write your code once. Then toggle between sequential and parallel iterators with a feature flag!
let a: Vec<i32> = (0..100).collect();
a.into_maybe_parallel_iterator()
.with_min_sequential(2)
.map(|n| -n)
.enumerate()
.flat_map(|(e, n)| vec![e as i32, n, n + 1000].into_maybe_parallel_iterator())
.for_each(|item| {
println!("par: {:?}", item);
})
into_maybe_par_itermaybe_par_itermaybe_par_iter_mutmaybe_par_sortmaybe_par_sort_unstablemaybe_par_sort_bymaybe_par_sort_unstable_bymaybe_par_sort_by_keymaybe_par_sort_unstable_by_keyUse the rayon feature flag to enable rayon parallelism.
The default is sequential ("rayoff" mode).
For now, only supports these iterator adapters:
collectenumeratefilter_mapfind_anyflat_mapfor_eachmapwith_min_sequential (no-op unless rayon feature enabled)*Only available for IndexedParallelIterator's if rayon feature enabled.
Licensed under either of
at your option.
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.