From 286f82f7451258a8db0869058f27e5bd34ee1b72 Mon Sep 17 00:00:00 2001 From: Stefan Schindler Date: Tue, 5 Sep 2017 17:23:38 +0200 Subject: [PATCH] Second example with zip --- src/range.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/range.rs b/src/range.rs index 3ac00aa01..7a0805076 100644 --- a/src/range.rs +++ b/src/range.rs @@ -19,6 +19,25 @@ use iter::internal::*; use std::ops::Range; /// Parallel iterator over a range +/// Implemented for `u32`, `i32`, `usize` and `isize`. +/// +/// ``` +/// use rayon::prelude::*; +/// +/// let p = (0..25usize).into_par_iter() +/// .zip(0..25usize) +/// .filter(|&(x, y)| x % 5 == 0 || y % 5 == 0) +/// .map(|(x, y)| x * y) +/// .fold(|| 0, |acc, cur| acc + cur) +/// .sum::(); +/// +/// let s = (0..25usize).zip(0..25) +/// .filter(|&(x, y)| x % 5 == 0 || y % 5 == 0) +/// .map(|(x, y)| x * y) +/// .sum(); +/// +/// assert_eq!(p, s); +/// ``` #[derive(Debug)] pub struct Iter { range: Range,