lending_iterator/lending_iterator/adapters/
filter.rs

1/// The <code>impl [LendingIterator]</code> returned by [`.filter()`][
2/// LendingIterator::filter()].
3pub
4struct Filter<I, F>
5where
6    I : LendingIterator,
7    F : FnMut(&'_ Item<'_, I>) -> bool,
8{
9    pub(in crate)
10    iter: I,
11
12    pub(in crate)
13    should_yield: F,
14}
15
16#[gat]
17impl<I, F> LendingIterator
18    for Filter<I, F>
19where
20    I : LendingIterator,
21    F : FnMut(&'_ Item<'_, I>) -> bool,
22{
23    type Item<'next>
24    where
25        Self : 'next,
26    =
27        Item<'next, I>
28    ;
29
30    fn next (
31        self: &'_ mut Filter<I, F>,
32    ) -> Option<Item<'_, I>>
33    {
34        self.iter.find(&mut self.should_yield)
35    }
36}