1use super::{plumbing::*, *};
2
3#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
12#[derive(Debug, Clone)]
13pub struct ZipEq<A: IndexedParallelIterator, B: IndexedParallelIterator> {
14 zip: Zip<A, B>,
15}
16
17impl<A, B> ZipEq<A, B>
18where
19 A: IndexedParallelIterator,
20 B: IndexedParallelIterator,
21{
22 pub(super) fn new(a: A, b: B) -> Self {
24 ZipEq {
25 zip: super::Zip::new(a, b),
26 }
27 }
28}
29
30impl<A, B> ParallelIterator for ZipEq<A, B>
31where
32 A: IndexedParallelIterator,
33 B: IndexedParallelIterator,
34{
35 type Item = (A::Item, B::Item);
36
37 fn drive_unindexed<C>(self, consumer: C) -> C::Result
38 where
39 C: UnindexedConsumer<Self::Item>,
40 {
41 bridge(self.zip, consumer)
42 }
43
44 fn opt_len(&self) -> Option<usize> {
45 Some(self.zip.len())
46 }
47}
48
49impl<A, B> IndexedParallelIterator for ZipEq<A, B>
50where
51 A: IndexedParallelIterator,
52 B: IndexedParallelIterator,
53{
54 fn drive<C>(self, consumer: C) -> C::Result
55 where
56 C: Consumer<Self::Item>,
57 {
58 bridge(self.zip, consumer)
59 }
60
61 fn len(&self) -> usize {
62 self.zip.len()
63 }
64
65 fn with_producer<CB>(self, callback: CB) -> CB::Output
66 where
67 CB: ProducerCallback<Self::Item>,
68 {
69 self.zip.with_producer(callback)
70 }
71}