Posted on

I’ve published my own parallel sequential iterator library for Rust, Parseq. Parseq provides an extension trait adding a map_parallel method to the standard iterator trait. It’s a drop-in-replacement for the standard map method.

use std::time::Duration;
use parseq::ParallelIterator;

let mut iter = [3,2,1]
  .map_parallel(|i| {
    // Insert heavy computation here ...

assert_eq!(, Some(6));
assert_eq!(, Some(4));
assert_eq!(, Some(2));
assert_eq!(, None);

See the repository for a real world example, and for the documentation.

Parseq is of course not the first crate providing a parallel map function for iterators. But I think it comes with a unique set of features:

In contrast, Rayon, the de-facto standard solution for Rust, doesn’t preserve the order of the original iterator. Pariter, a good sequential alternative addressing this exact issue, doesn’t support infinite iterators; though it provides more features than Parseq.

Therefore, I invite you to give Parseq a try, and send me some feedback.