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
use crate::LendingIterator;

/// A lending iterator that iterates over an iterator.
#[derive(Clone)]
pub struct IntoLending<I: Iterator> {
    iter: I,
}

impl<I: Iterator> IntoLending<I> {
    pub(crate) fn new(iter: I) -> Self {
        Self { iter }
    }
}

impl<I: Iterator> LendingIterator for IntoLending<I> {
    type Item<'a> = I::Item where Self: 'a;

    fn next(&mut self) -> Option<Self::Item<'_>> {
        self.iter.next()
    }

    fn size_hint(&self) -> (usize, Option<usize>) {
        self.iter.size_hint()
    }
}