async_iterator/iter/lend_mut.rs
1use crate::Iterator;
2use crate::LendingIterator;
3
4/// The iterator returned from `AsyncIterator::lend`.
5#[derive(Debug)]
6pub struct LendMut<I: Iterator>(I);
7
8impl<I: Iterator> LendMut<I> {
9 pub(crate) fn new(i: I) -> Self {
10 Self(i)
11 }
12}
13
14impl<I: Iterator> LendingIterator for LendMut<I> {
15 type Item<'a> = (&'a mut I, I::Item)
16 where
17 Self: 'a;
18
19 async fn next(&mut self) -> Option<Self::Item<'_>> {
20 let item = self.0.next().await;
21 item.map(move |item| (&mut self.0, item))
22 }
23}