summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorStefan Kreutz <mail@skreutz.com>2023-06-07 15:01:52 +0200
committerStefan Kreutz <mail@skreutz.com>2023-06-07 15:01:52 +0200
commit40b3a387547577720f289669d34a55254ecf9ce9 (patch)
treec6ff2d3c91a7a70c18cab58dc163114bc314d9bf /src/lib.rs
parente6b81581a1095e5e05a6c8175d4dc4fbb0c0a9bf (diff)
downloadparseq-40b3a387547577720f289669d34a55254ecf9ce9.tar
Revise ParallelIterator trait usage examples
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1359ec6..f71965b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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);
/// ```
Generated by cgit. See skreutz.com for my tech blog and contact information.