micro_moka/unsync/
iter.rs1use super::{Cache, ValueEntry};
2
3use std::{hash::Hash, rc::Rc};
4
5type HashMapIter<'i, K, V> = std::collections::hash_map::Iter<'i, Rc<K>, ValueEntry<K, V>>;
6
7pub struct Iter<'i, K, V> {
8 iter: HashMapIter<'i, K, V>,
9}
10
11impl<'i, K, V> Iter<'i, K, V> {
12 pub(crate) fn new(
13 _cache: &'i Cache<K, V, impl std::hash::BuildHasher>,
14 iter: HashMapIter<'i, K, V>,
15 ) -> Self {
16 Self { iter }
17 }
18}
19
20impl<'i, K, V> Iterator for Iter<'i, K, V>
21where
22 K: Hash + Eq,
23{
24 type Item = (&'i K, &'i V);
25
26 fn next(&mut self) -> Option<Self::Item> {
27 if let Some((k, entry)) = self.iter.next() {
28 return Some((k, &entry.value));
29 }
30 None
31 }
32}