diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -72,14 +72,16 @@ pub trait ParallelIterator { /// use std::time::Duration; /// use parseq::ParallelIterator; /// - /// let mut iter = (0..3) + /// let mut iter = [3,2,1] + /// .into_iter() /// .map_parallel(|i| { - /// std::thread::sleep(Duration::from_millis((i % 3) * 10)); - /// i + /// // Insert heavy computation here ... + /// std::thread::sleep(Duration::from_millis(100*i)); + /// 2*i /// }); /// - /// assert_eq!(iter.next(), Some(0)); - /// assert_eq!(iter.next(), Some(1)); + /// assert_eq!(iter.next(), Some(6)); + /// assert_eq!(iter.next(), Some(4)); /// assert_eq!(iter.next(), Some(2)); /// assert_eq!(iter.next(), None); /// ``` @@ -119,14 +121,15 @@ pub trait ParallelIterator { /// use std::time::Duration; /// use parseq::ParallelIterator; /// - /// let mut iter = (0..3) + /// let mut iter = [3,2,1] + /// .into_iter() /// .map_parallel_limit(2, 16, |i| { - /// std::thread::sleep(Duration::from_millis((i % 3) * 10)); - /// i + /// std::thread::sleep(Duration::from_millis(100*i)); + /// 2*i /// }); /// - /// assert_eq!(iter.next(), Some(0)); - /// assert_eq!(iter.next(), Some(1)); + /// assert_eq!(iter.next(), Some(6)); + /// assert_eq!(iter.next(), Some(4)); /// assert_eq!(iter.next(), Some(2)); /// assert_eq!(iter.next(), None); /// ``` |