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
/// The <code>impl [LendingIterator]</code> returned by [`.fuse()`][
/// LendingIterator::fuse()].
pub
struct Fuse<I : LendingIterator>(
    pub(in crate) Option<I>,
);

#[gat]
impl<I : LendingIterator> LendingIterator for Fuse<I> {
    type Item<'next>
    where
        Self : 'next,
    =
        Item<'next, I>
    ;

    fn next (self: &'_ mut Self)
      -> Option<Item<'_, I>>
    {
        let mut this = self;
        let got_none = polonius!(|this| -> Option<Item<'polonius, I>> {
            if let Some(iter) = &mut this.0 {
                if let item @ Some(_) = iter.next() {
                    polonius_return!(item);
                } else {
                    true
                }
            } else {
                false
            }
        });
        if got_none {
            this.0 = None;
        }
        None
    }
}