Skip to content

Commit

Permalink
Format and comment the example for method map_with of the ParallelIte…
Browse files Browse the repository at this point in the history
…rator
  • Loading branch information
oddg committed Jan 24, 2018
1 parent d2c68cf commit 8936322
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,16 @@ pub trait ParallelIterator: Sized + Send {
///
/// let (sender, receiver) = channel();
///
/// let mut par_iter = (0..5).into_par_iter().map_with(sender, |s, x| { s.send(x).unwrap(); x });
/// let a: Vec<_> = par_iter.collect();
///
/// let mut b: Vec<_> = receiver.iter().collect();
/// let a: Vec<_> = (0..5)
/// .into_par_iter() // iterating over i32
/// .map_with(sender, |s, x| {
/// s.send(x).unwrap(); // sending i32 values through the channel
/// x // returning i32
/// })
/// .collect(); // collecting the returned values into a vector
///
/// let mut b: Vec<_> = receiver.iter() // iterating over the values in the channel
/// .collect(); // and collecting them
/// b.sort();
///
/// assert_eq!(a, b);
Expand Down

0 comments on commit 8936322

Please sign in to comment.