1 use crate::setref::multiple::RefMulti;
2 use crate::t::Map;
3 use core::hash::{BuildHasher, Hash};
4 
5 pub struct OwningIter<K, S> {
6     inner: crate::iter::OwningIter<K, (), S>,
7 }
8 
9 impl<K: Eq + Hash, S: BuildHasher + Clone> OwningIter<K, S> {
new(inner: crate::iter::OwningIter<K, (), S>) -> Self10     pub(crate) fn new(inner: crate::iter::OwningIter<K, (), S>) -> Self {
11         Self { inner }
12     }
13 }
14 
15 impl<K: Eq + Hash, S: BuildHasher + Clone> Iterator for OwningIter<K, S> {
16     type Item = K;
17 
next(&mut self) -> Option<Self::Item>18     fn next(&mut self) -> Option<Self::Item> {
19         self.inner.next().map(|(k, _)| k)
20     }
21 }
22 
23 unsafe impl<K, S> Send for OwningIter<K, S>
24 where
25     K: Eq + Hash + Send,
26     S: BuildHasher + Clone + Send,
27 {
28 }
29 
30 unsafe impl<K, S> Sync for OwningIter<K, S>
31 where
32     K: Eq + Hash + Sync,
33     S: BuildHasher + Clone + Sync,
34 {
35 }
36 
37 pub struct Iter<'a, K, S, M> {
38     inner: crate::iter::Iter<'a, K, (), S, M>,
39 }
40 
41 unsafe impl<'a, 'i, K, S, M> Send for Iter<'i, K, S, M>
42 where
43     K: 'a + Eq + Hash + Send,
44     S: 'a + BuildHasher + Clone,
45     M: Map<'a, K, (), S>,
46 {
47 }
48 
49 unsafe impl<'a, 'i, K, S, M> Sync for Iter<'i, K, S, M>
50 where
51     K: 'a + Eq + Hash + Sync,
52     S: 'a + BuildHasher + Clone,
53     M: Map<'a, K, (), S>,
54 {
55 }
56 
57 impl<'a, K: Eq + Hash, S: 'a + BuildHasher + Clone, M: Map<'a, K, (), S>> Iter<'a, K, S, M> {
new(inner: crate::iter::Iter<'a, K, (), S, M>) -> Self58     pub(crate) fn new(inner: crate::iter::Iter<'a, K, (), S, M>) -> Self {
59         Self { inner }
60     }
61 }
62 
63 impl<'a, K: Eq + Hash, S: 'a + BuildHasher + Clone, M: Map<'a, K, (), S>> Iterator
64     for Iter<'a, K, S, M>
65 {
66     type Item = RefMulti<'a, K, S>;
67 
next(&mut self) -> Option<Self::Item>68     fn next(&mut self) -> Option<Self::Item> {
69         self.inner.next().map(RefMulti::new)
70     }
71 }
72