Parallelize any iterator!
This code is copy-pasted from examples/example_1.rs
.
```rust extern crate parallel_iterator;
use parallel_iterator::ParallelIterator;
fn dosomework(i: u32) -> u32 { i + 1 // let's pretend this is a heavy calculation }
fn main() { for i in ParallelIterator::new(|| (0u32..100), || dosomework) { println!("Got a result: {}!", i); } } ```
This code is copy-pasted from examples/example_2.rs
.
```rust extern crate parallel_iterator;
use parallel_iterator::ParallelIterator;
fn dosomework(i: usize, out: &mut Vec
fn main() { const MAX: usize = 1000; let xformctor = || { let mut buffer = Vec::withcapacity(MAX); move |i| { buffer.clear(); // Clear but keep the internal allocation. dosomework(i, &mut buffer); buffer.last().map(|u| *u) // This is just an example value. } }; for i in ParallelIterator::new(|| (0..MAX), xform_ctor) { match i { Some(i) => println!("Got Some({})!", i), None => println!("Got None!"), } } } ```
Please see the documentation on the ParallelIterator struct for more details.
Licensed under either of
at your option.