Coverage Report

Created: 2026-08-31 07:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-1.12.0/src/par_either.rs
Line
Count
Source
1
use crate::iter::plumbing::*;
2
use crate::iter::Either::{Left, Right};
3
use crate::iter::*;
4
5
/// `Either<L, R>` is a parallel iterator if both `L` and `R` are parallel iterators.
6
impl<L, R> ParallelIterator for Either<L, R>
7
where
8
    L: ParallelIterator,
9
    R: ParallelIterator<Item = L::Item>,
10
{
11
    type Item = L::Item;
12
13
0
    fn drive_unindexed<C>(self, consumer: C) -> C::Result
14
0
    where
15
0
        C: UnindexedConsumer<Self::Item>,
16
    {
17
0
        match self {
18
0
            Left(iter) => iter.drive_unindexed(consumer),
19
0
            Right(iter) => iter.drive_unindexed(consumer),
20
        }
21
0
    }
22
23
0
    fn opt_len(&self) -> Option<usize> {
24
0
        self.as_ref().either(L::opt_len, R::opt_len)
25
0
    }
26
}
27
28
impl<L, R> IndexedParallelIterator for Either<L, R>
29
where
30
    L: IndexedParallelIterator,
31
    R: IndexedParallelIterator<Item = L::Item>,
32
{
33
0
    fn drive<C>(self, consumer: C) -> C::Result
34
0
    where
35
0
        C: Consumer<Self::Item>,
36
    {
37
0
        match self {
38
0
            Left(iter) => iter.drive(consumer),
39
0
            Right(iter) => iter.drive(consumer),
40
        }
41
0
    }
42
43
0
    fn len(&self) -> usize {
44
0
        self.as_ref().either(L::len, R::len)
45
0
    }
46
47
0
    fn with_producer<CB>(self, callback: CB) -> CB::Output
48
0
    where
49
0
        CB: ProducerCallback<Self::Item>,
50
    {
51
0
        match self {
52
0
            Left(iter) => iter.with_producer(callback),
53
0
            Right(iter) => iter.with_producer(callback),
54
        }
55
0
    }
56
}
57
58
/// `Either<L, R>` can be extended if both `L` and `R` are parallel extendable.
59
impl<L, R, T> ParallelExtend<T> for Either<L, R>
60
where
61
    L: ParallelExtend<T>,
62
    R: ParallelExtend<T>,
63
    T: Send,
64
{
65
0
    fn par_extend<I>(&mut self, par_iter: I)
66
0
    where
67
0
        I: IntoParallelIterator<Item = T>,
68
    {
69
0
        match self.as_mut() {
70
0
            Left(collection) => collection.par_extend(par_iter),
71
0
            Right(collection) => collection.par_extend(par_iter),
72
        }
73
0
    }
74
}