1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use crateConcurrentIter;
/// A regular [`Iterator`] which is created from and linked to and
/// pulls its elements from a [`ConcurrentIter`].
///
/// It can be created using the [`item_puller_with_idx`] method of a concurrent iterator.
///
/// This is similar to [`ItemPuller`] except that this iterator additionally returns the
/// indices of the elements in the source concurrent iterator.
///
/// [`item_puller_with_idx`]: crate::ConcurrentIter::item_puller_with_idx
/// [`ItemPuller`]: crate::ItemPuller
///
/// # Examples
///
/// See the [`ItemPuller`] for detailed examples.
/// The following example only demonstrates the additional index that is returned by the
/// next method of the `EnumeratedItemPuller`.
///
/// ```
/// use orx_concurrent_iter::*;
///
/// let num_threads = 4;
/// let data: Vec<_> = (0..100).map(|x| x.to_string()).collect();
/// let con_iter = data.con_iter();
///
/// std::thread::scope(|s| {
/// for _ in 0..num_threads {
/// s.spawn(|| {
/// for (idx, value) in con_iter.item_puller_with_idx() {
/// assert_eq!(value, &idx.to_string());
/// }
/// });
/// }
/// });
/// ```