Coverage Report

Created: 2025-02-26 06:58

/rust/registry/src/index.crates.io-6f17d22bba15001f/petgraph-0.7.1/src/iter_utils.rs
Line
Count
Source (jump to first uncovered line)
1
pub trait IterUtilsExt: Iterator {
2
    /// Return the first element that maps to `Some(_)`, or None if the iterator
3
    /// was exhausted.
4
0
    fn ex_find_map<F, R>(&mut self, mut f: F) -> Option<R>
5
0
    where
6
0
        F: FnMut(Self::Item) -> Option<R>,
7
0
    {
8
0
        for elt in self {
9
0
            if let result @ Some(_) = f(elt) {
10
0
                return result;
11
0
            }
12
        }
13
0
        None
14
0
    }
15
16
    /// Return the last element from the back that maps to `Some(_)`, or
17
    /// None if the iterator was exhausted.
18
0
    fn ex_rfind_map<F, R>(&mut self, mut f: F) -> Option<R>
19
0
    where
20
0
        F: FnMut(Self::Item) -> Option<R>,
21
0
        Self: DoubleEndedIterator,
22
0
    {
23
0
        while let Some(elt) = self.next_back() {
24
0
            if let result @ Some(_) = f(elt) {
25
0
                return result;
26
0
            }
27
        }
28
0
        None
29
0
    }
30
}
31
32
impl<I> IterUtilsExt for I where I: Iterator {}