Debian Codegraph @

src/impls/std/hashmap.rs

raw symbols SCIP
1 use crate::{
2 Clear, Collection, CollectionMut, CollectionRef, Get, GetKeyValue, GetMut, Iter, Keyed,
3 KeyedRef, Len, MapInsert, MapIter, MapIterMut, Remove, SimpleCollectionMut,
4 SimpleCollectionRef, SimpleKeyedRef,
5 };
6 use std::{borrow::Borrow, collections::HashMap, hash::Hash};
7
8 impl<K, V> Collection for HashMap<K, V> {
9 type Item = V;
10 }
11
12 impl<K, V> CollectionRef for HashMap<K, V> {
13 type ItemRef<'a> = &'a V where Self: 'a;
14
15 crate::covariant_item_ref!();
16 }
17
18 impl<K, V> CollectionMut for HashMap<K, V> {
19 type ItemMut<'a> = &'a mut V where Self: 'a;
20
21 crate::covariant_item_mut!();
22 }
23
24 impl<K, V> SimpleCollectionRef for HashMap<K, V> {
25 crate::simple_collection_ref!();
26 }
27
28 impl<K, V> SimpleCollectionMut for HashMap<K, V> {
29 crate::simple_collection_mut!();
30 }
31
32 impl<K, V> Keyed for HashMap<K, V> {
33 type Key = K;
34 }
35
36 impl<K, V> KeyedRef for HashMap<K, V> {
37 type KeyRef<'a> = &'a K where Self: 'a;
38
39 crate::covariant_key_ref!();
40 }
41
42 impl<K, V> SimpleKeyedRef for HashMap<K, V> {
43 crate::simple_keyed_ref!();
44 }
45
46 impl<K, V> Len for HashMap<K, V> {
47 #[inline(always)]
48 fn len(&self) -> usize {
49 self.len()
50 }
51
52 #[inline(always)]
53 fn is_empty(&self) -> bool {
54 self.is_empty()
55 }
56 }
57
58 impl<'a, Q, K: Hash + Eq, V> Get<&'a Q> for HashMap<K, V>
59 where
60 K: Borrow<Q>,
61 Q: Hash + Eq + ?Sized,
62 {
63 #[inline(always)]
64 fn get(&self, key: &'a Q) -> Option<&V> {
65 self.get(key)
66 }
67 }
68
69 impl<'a, Q, K: Hash + Eq, V> GetMut<&'a Q> for HashMap<K, V>
70 where
71 K: Borrow<Q>,
72 Q: Hash + Eq + ?Sized,
73 {
74 #[inline(always)]
75 fn get_mut(&mut self, key: &'a Q) -> Option<&mut V> {
76 self.get_mut(key)
77 }
78 }
79
80 impl<'a, Q, K: Hash + Eq, V> GetKeyValue<&'a Q> for HashMap<K, V>
81 where
82 K: Borrow<Q>,
83 Q: Hash + Eq + ?Sized,
84 {
85 #[inline(always)]
86 fn get_key_value(&self, key: &'a Q) -> Option<(&K, &V)> {
87 self.get_key_value(key)
88 }
89 }
90
91 impl<K: Hash + Eq, V> MapInsert<K> for HashMap<K, V> {
92 type Output = Option<V>;
93
94 #[inline(always)]
95 fn insert(&mut self, key: K, value: V) -> Option<V> {
96 self.insert(key, value)
97 }
98 }
99
100 impl<'a, Q, K: Hash + Eq, V> Remove<&'a Q> for HashMap<K, V>
101 where
102 K: Borrow<Q>,
103 Q: Hash + Eq + ?Sized,
104 {
105 #[inline(always)]
106 fn remove(&mut self, key: &'a Q) -> Option<V> {
107 self.remove(key)
108 }
109 }
110
111 impl<K, V> Clear for HashMap<K, V> {
112 #[inline(always)]
113 fn clear(&mut self) {
114 self.clear()
115 }
116 }
117
118 impl<K, V> Iter for HashMap<K, V> {
119 type Iter<'a> = std::collections::hash_map::Values<'a, K, V> where Self: 'a;
120
121 #[inline(always)]
122 fn iter(&self) -> Self::Iter<'_> {
123 self.values()
124 }
125 }
126
127 impl<K, V> MapIter for HashMap<K, V> {
128 type Iter<'a> = std::collections::hash_map::Iter<'a, K, V> where Self: 'a;
129
130 #[inline(always)]
131 fn iter(&self) -> Self::Iter<'_> {
132 self.iter()
133 }
134 }
135
136 impl<K, V> MapIterMut for HashMap<K, V> {
137 type IterMut<'a> = std::collections::hash_map::IterMut<'a, K, V> where Self: 'a;
138
139 #[inline(always)]
140 fn iter_mut(&mut self) -> Self::IterMut<'_> {
141 self.iter_mut()
142 }
143 }