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
use std::fmt::Debug;
use super::Receiver;
pub struct RefIter<'queue, T> {
recv: &'queue mut Receiver<T>,
}
impl<'queue, T> RefIter<'queue, T> {
pub(crate) fn new<'outer_queue>(recv: &'outer_queue mut Receiver<T>) -> Self
where
'outer_queue: 'queue,
{
Self { recv }
}
}
impl<'queue, T> Iterator for RefIter<'queue, T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.recv.dequeue()
}
}
impl<'queue, T> Debug for RefIter<'queue, T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Ref-Iter ()")
}
}