Skip to content

Commit

Permalink
Second example with zip
Browse files Browse the repository at this point in the history
  • Loading branch information
dns2utf8 committed Sep 22, 2017
1 parent a74b79c commit 286f82f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<usize>();
///
/// 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<T> {
range: Range<T>,
Expand Down

0 comments on commit 286f82f

Please sign in to comment.