nolock/queues/mpsc/jiffy/
ref_iter.rs

1use core::fmt::Debug;
2
3use super::Receiver;
4
5/// Iterator for all Elements from the Queue
6///
7/// This Iterator behaves nearly identical to the [`OwnedIter`](super::OwnedIter)
8/// with the only difference being, that this Iterator does not consume
9/// the Queue-Receiver and therefore allows you to use the Receiver
10/// for some other checks later on as well
11pub struct RefIter<'queue, T> {
12    recv: &'queue mut Receiver<T>,
13}
14
15impl<'queue, T> RefIter<'queue, T> {
16    pub(crate) fn new<'outer_queue>(recv: &'outer_queue mut Receiver<T>) -> Self
17    where
18        'outer_queue: 'queue,
19    {
20        Self { recv }
21    }
22}
23
24impl<'queue, T> Iterator for RefIter<'queue, T> {
25    type Item = T;
26
27    fn next(&mut self) -> Option<Self::Item> {
28        self.recv.dequeue()
29    }
30}
31
32impl<'queue, T> Debug for RefIter<'queue, T> {
33    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
34        write!(f, "Ref-Iter ()")
35    }
36}