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

/// A regular `Iterator` crated from the [`ConcurrentIter::values`] method.
///
/// Its `next` method does nothing but call [`ConcurrentIter::next`] method.
/// This iterator is a wrapper to allow using the concurrent iterator in a `for` loop directly.
pub struct ConIterValues<'a, C>
where
    C: ConcurrentIter,
{
    con_iter: &'a C,
}

impl<'a, C: ConcurrentIter> From<&'a C> for ConIterValues<'a, C> {
    fn from(con_iter: &'a C) -> Self {
        Self { con_iter }
    }
}

impl<'a, C> Iterator for ConIterValues<'a, C>
where
    C: ConcurrentIter,
{
    type Item = C::Item;

    #[inline(always)]
    fn next(&mut self) -> Option<Self::Item> {
        self.con_iter.next()
    }
}