diff options
author | Stefan Kreutz <mail@skreutz.com> | 2023-06-07 15:01:52 +0200 |
---|---|---|
committer | Stefan Kreutz <mail@skreutz.com> | 2023-06-07 15:01:52 +0200 |
commit | 40b3a387547577720f289669d34a55254ecf9ce9 (patch) | |
tree | c6ff2d3c91a7a70c18cab58dc163114bc314d9bf | |
parent | e6b81581a1095e5e05a6c8175d4dc4fbb0c0a9bf (diff) | |
download | parseq-40b3a387547577720f289669d34a55254ecf9ce9.tar |
Revise ParallelIterator trait usage examples
-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); /// ``` |