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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
use crate::{
Clear, Collection, CollectionMut, CollectionRef, Get, GetMut, Iter, Keyed, KeyedRef, Len,
MapInsert, MapIter, MapIterMut, Remove,
};
use std::{borrow::Borrow, collections::HashMap, hash::Hash};
impl<K, V> Collection for HashMap<K, V> {
type Item = V;
}
impl<K, V> CollectionRef for HashMap<K, V> {
type ItemRef<'a>
where
Self: 'a,
= &'a V;
crate::covariant_item_ref!();
}
impl<K, V> CollectionMut for HashMap<K, V> {
type ItemMut<'a>
where
Self: 'a,
= &'a mut V;
crate::covariant_item_mut!();
}
impl<K, V> Keyed for HashMap<K, V> {
type Key = K;
}
impl<K, V> KeyedRef for HashMap<K, V> {
type KeyRef<'a>
where
Self: 'a,
= &'a K;
crate::covariant_key_ref!();
}
impl<K, V> Len for HashMap<K, V> {
#[inline(always)]
fn len(&self) -> usize {
self.len()
}
#[inline(always)]
fn is_empty(&self) -> bool {
self.is_empty()
}
}
impl<'a, Q, K: Hash + Eq, V> Get<&'a Q> for HashMap<K, V>
where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
{
#[inline(always)]
fn get(&self, key: &'a Q) -> Option<&V> {
self.get(key)
}
}
impl<'a, Q, K: Hash + Eq, V> GetMut<&'a Q> for HashMap<K, V>
where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
{
#[inline(always)]
fn get_mut(&mut self, key: &'a Q) -> Option<&mut V> {
self.get_mut(key)
}
}
impl<K: Hash + Eq, V> MapInsert<K> for HashMap<K, V> {
type Output = Option<V>;
#[inline(always)]
fn insert(&mut self, key: K, value: V) -> Option<V> {
self.insert(key, value)
}
}
impl<'a, Q, K: Hash + Eq, V> Remove<&'a Q> for HashMap<K, V>
where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
{
#[inline(always)]
fn remove(&mut self, key: &'a Q) -> Option<V> {
self.remove(key)
}
}
impl<K, V> Clear for HashMap<K, V> {
#[inline(always)]
fn clear(&mut self) {
self.clear()
}
}
impl<K, V> Iter for HashMap<K, V> {
type Iter<'a>
where
Self: 'a,
= std::collections::hash_map::Values<'a, K, V>;
#[inline(always)]
fn iter(&self) -> Self::Iter<'_> {
self.values()
}
}
impl<K, V> MapIter for HashMap<K, V> {
type Iter<'a>
where
Self: 'a,
= std::collections::hash_map::Iter<'a, K, V>;
#[inline(always)]
fn iter(&self) -> Self::Iter<'_> {
self.iter()
}
}
impl<K, V> MapIterMut for HashMap<K, V> {
type IterMut<'a>
where
Self: 'a,
= std::collections::hash_map::IterMut<'a, K, V>;
#[inline(always)]
fn iter_mut(&mut self) -> Self::IterMut<'_> {
self.iter_mut()
}
}