| 1 | //! A bimap backed by two `HashMap`s. |
| 2 | |
| 3 | use craterust-analyzer cargo bimap 0.6.3 crate/::{ |
| 4 | memrust-analyzer cargo bimap 0.6.3 mem/::{Refrust-analyzer cargo bimap 0.6.3 mem/Ref#, Wrapperrust-analyzer cargo bimap 0.6.3 mem/Wrapper#}, |
| 5 | Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#, |
| 6 | }; |
| 7 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 8 | borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#, |
| 9 | collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::{hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/, HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#}, |
| 10 | fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, |
| 11 | hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::{BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#}, |
| 12 | iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::{Extendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/Extend#, FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#, FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator#}, |
| 13 | rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#, |
| 14 | }; |
| 15 | |
| 16 | /// A bimap backed by two `HashMap`s. |
| 17 | /// |
| 18 | /// See the [module-level documentation] for more details and examples. |
| 19 | /// |
| 20 | /// [module-level documentation]: crate |
| 21 | pub struct BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS = hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::RandomStaterust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/RandomState#, RS = hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::RandomStaterust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/RandomState#> { |
| 22 | left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<L>, Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<R>, LS>, |
| 23 | right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<R>, Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<L>, RS>, |
| 24 | } |
| 25 | |
| 26 | impl<L, R> BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::RandomStaterust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/RandomState#, hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::RandomStaterust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/RandomState#> |
| 27 | where |
| 28 | L: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 29 | R: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 30 | { |
| 31 | /// Creates an empty `BiHashMap`. |
| 32 | /// |
| 33 | /// # Examples |
| 34 | /// |
| 35 | /// ``` |
| 36 | /// use bimap::BiHashMap; |
| 37 | /// |
| 38 | /// let bimap = BiHashMap::<char, i32>::new(); |
| 39 | /// ``` |
| 40 | pub fn newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().() -> Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`] { |
| 41 | Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`] { |
| 42 | left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(), |
| 43 | right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(), |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /// Creates a new empty `BiHashMap` with the given capacity. |
| 48 | /// |
| 49 | /// # Examples |
| 50 | /// |
| 51 | /// ``` |
| 52 | /// use bimap::BiHashMap; |
| 53 | /// |
| 54 | /// let bimap = BiHashMap::<char, i32>::with_capacity(10); |
| 55 | /// assert!(bimap.capacity() >= 10); |
| 56 | /// ``` |
| 57 | pub fn with_capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]with_capacity().(capacity: usize) -> Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`] { |
| 58 | Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`] { |
| 59 | left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::with_capacityrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]with_capacity().(capacity), |
| 60 | right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::with_capacityrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]with_capacity().(capacity), |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | impl<L, R, LS, RS> BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 66 | where |
| 67 | L: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 68 | R: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 69 | { |
| 70 | /// Returns the number of left-right pairs in the bimap. |
| 71 | /// |
| 72 | /// # Examples |
| 73 | /// |
| 74 | /// ``` |
| 75 | /// use bimap::BiHashMap; |
| 76 | /// |
| 77 | /// let mut bimap = BiHashMap::new(); |
| 78 | /// bimap.insert('a', 1); |
| 79 | /// bimap.insert('b', 2); |
| 80 | /// bimap.insert('c', 3); |
| 81 | /// assert_eq!(bimap.len(), 3); |
| 82 | /// ``` |
| 83 | pub fn lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(&self) -> usize { |
| 84 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]len().() |
| 85 | } |
| 86 | |
| 87 | /// Returns `true` if the bimap contains no left-right pairs, and `false` |
| 88 | /// otherwise. |
| 89 | /// |
| 90 | /// # Examples |
| 91 | /// |
| 92 | /// ``` |
| 93 | /// use bimap::BiHashMap; |
| 94 | /// |
| 95 | /// let mut bimap = BiHashMap::new(); |
| 96 | /// assert!(bimap.is_empty()); |
| 97 | /// bimap.insert('a', 1); |
| 98 | /// assert!(!bimap.is_empty()); |
| 99 | /// bimap.remove_by_right(&1); |
| 100 | /// assert!(bimap.is_empty()); |
| 101 | /// ``` |
| 102 | pub fn is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().(&self) -> bool { |
| 103 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]is_empty().() |
| 104 | } |
| 105 | |
| 106 | /// Returns a lower bound on the number of left-right pairs the `BiHashMap` |
| 107 | /// can store without reallocating memory. |
| 108 | /// |
| 109 | /// # Examples |
| 110 | /// |
| 111 | /// ``` |
| 112 | /// use bimap::BiHashMap; |
| 113 | /// |
| 114 | /// let bimap = BiHashMap::<char, i32>::with_capacity(10); |
| 115 | /// assert!(bimap.capacity() >= 10); |
| 116 | /// ``` |
| 117 | pub fn capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().(&self) -> usize { |
| 118 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..capacityrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]capacity().().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..capacityrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]capacity().()) |
| 119 | } |
| 120 | |
| 121 | /// Removes all left-right pairs from the bimap. |
| 122 | /// |
| 123 | /// # Examples |
| 124 | /// |
| 125 | /// ``` |
| 126 | /// use bimap::BiHashMap; |
| 127 | /// |
| 128 | /// let mut bimap = BiHashMap::new(); |
| 129 | /// bimap.insert('a', 1); |
| 130 | /// bimap.insert('b', 2); |
| 131 | /// bimap.insert('c', 3); |
| 132 | /// bimap.clear(); |
| 133 | /// assert!(bimap.len() == 0); |
| 134 | /// ``` |
| 135 | pub fn clearrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]clear().(&mut self) { |
| 136 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..clearrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]clear().(); |
| 137 | self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..clearrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]clear().(); |
| 138 | } |
| 139 | |
| 140 | /// Creates an iterator over the left-right pairs in the bimap in arbitrary |
| 141 | /// order. |
| 142 | /// |
| 143 | /// The iterator element type is `(&L, &R)`. |
| 144 | /// |
| 145 | /// # Examples |
| 146 | /// |
| 147 | /// ``` |
| 148 | /// use bimap::BiHashMap; |
| 149 | /// |
| 150 | /// let mut bimap = BiHashMap::new(); |
| 151 | /// bimap.insert('a', 1); |
| 152 | /// bimap.insert('b', 2); |
| 153 | /// bimap.insert('c', 3); |
| 154 | /// |
| 155 | /// for (left, right) in bimap.iter() { |
| 156 | /// println!("({}, {})", left, right); |
| 157 | /// } |
| 158 | /// ``` |
| 159 | pub fn iterrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]iter().(&self) -> Iterrust-analyzer cargo bimap 0.6.3 hash/Iter#<'_, L, R> { |
| 160 | Iterrust-analyzer cargo bimap 0.6.3 hash/Iter# { |
| 161 | innerrust-analyzer cargo bimap 0.6.3 hash/Iter#inner.: self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().(), |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | /// Creates an iterator over the left values in the bimap in arbitrary |
| 166 | /// order. |
| 167 | /// |
| 168 | /// The iterator element type is `&L`. |
| 169 | /// |
| 170 | /// # Examples |
| 171 | /// |
| 172 | /// ``` |
| 173 | /// use bimap::BiHashMap; |
| 174 | /// |
| 175 | /// let mut bimap = BiHashMap::new(); |
| 176 | /// bimap.insert('a', 1); |
| 177 | /// bimap.insert('b', 2); |
| 178 | /// bimap.insert('c', 3); |
| 179 | /// |
| 180 | /// for char_value in bimap.left_values() { |
| 181 | /// println!("{}", char_value); |
| 182 | /// } |
| 183 | /// ``` |
| 184 | pub fn left_valuesrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]left_values().(&self) -> LeftValuesrust-analyzer cargo bimap 0.6.3 hash/LeftValues#<'_, L, R> { |
| 185 | LeftValuesrust-analyzer cargo bimap 0.6.3 hash/LeftValues# { |
| 186 | innerrust-analyzer cargo bimap 0.6.3 hash/LeftValues#inner.: self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().(), |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | /// Creates an iterator over the right values in the bimap in arbitrary |
| 191 | /// order. |
| 192 | /// |
| 193 | /// The iterator element type is `&R`. |
| 194 | /// |
| 195 | /// # Examples |
| 196 | /// |
| 197 | /// ``` |
| 198 | /// use bimap::BiHashMap; |
| 199 | /// |
| 200 | /// let mut bimap = BiHashMap::new(); |
| 201 | /// bimap.insert('a', 1); |
| 202 | /// bimap.insert('b', 2); |
| 203 | /// bimap.insert('c', 3); |
| 204 | /// |
| 205 | /// for int_value in bimap.right_values() { |
| 206 | /// println!("{}", int_value); |
| 207 | /// } |
| 208 | /// ``` |
| 209 | pub fn right_valuesrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]right_values().(&self) -> RightValuesrust-analyzer cargo bimap 0.6.3 hash/RightValues#<'_, L, R> { |
| 210 | RightValuesrust-analyzer cargo bimap 0.6.3 hash/RightValues# { |
| 211 | innerrust-analyzer cargo bimap 0.6.3 hash/RightValues#inner.: self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().(), |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | impl<L, R, LS, RS> BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 217 | where |
| 218 | L: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 219 | R: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 220 | LS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 221 | RS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 222 | { |
| 223 | /// Creates a new empty `BiHashMap` using `hash_builder_left` to hash left |
| 224 | /// values and `hash_builder_right` to hash right values. |
| 225 | /// |
| 226 | /// # Examples |
| 227 | /// |
| 228 | /// ``` |
| 229 | /// use std::collections::hash_map::RandomState; |
| 230 | /// use bimap::BiHashMap; |
| 231 | /// |
| 232 | /// let s_left = RandomState::new(); |
| 233 | /// let s_right = RandomState::new(); |
| 234 | /// let mut bimap = BiHashMap::<char, i32>::with_hashers(s_left, s_right); |
| 235 | /// bimap.insert('a', 42); |
| 236 | /// ``` |
| 237 | pub fn with_hashersrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]with_hashers().(hash_builder_left: LS, hash_builder_right: RS) -> Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`] { |
| 238 | Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`] { |
| 239 | left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::with_hasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`]with_hasher().(hash_builder_left), |
| 240 | right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::with_hasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`]with_hasher().(hash_builder_right), |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | /// Creates a new empty `BiHashMap` with the given capacity, using |
| 245 | /// `hash_builder_left` to hash left values and `hash_builder_right` to |
| 246 | /// hash right values. |
| 247 | /// |
| 248 | /// # Examples |
| 249 | /// |
| 250 | /// ``` |
| 251 | /// use std::collections::hash_map::RandomState; |
| 252 | /// use bimap::BiHashMap; |
| 253 | /// |
| 254 | /// let s_left = RandomState::new(); |
| 255 | /// let s_right = RandomState::new(); |
| 256 | /// let bimap = BiHashMap::<char, i32>::with_capacity_and_hashers(10, s_left, s_right); |
| 257 | /// assert!(bimap.capacity() >= 10); |
| 258 | /// ``` |
| 259 | pub fn with_capacity_and_hashersrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]with_capacity_and_hashers().( |
| 260 | capacity: usize, |
| 261 | hash_builder_left: LS, |
| 262 | hash_builder_right: RS, |
| 263 | ) -> Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`] { |
| 264 | Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`] { |
| 265 | left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::with_capacity_and_hasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`]with_capacity_and_hasher().(capacity, hash_builder_left), |
| 266 | right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::with_capacity_and_hasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`]with_capacity_and_hasher().(capacity, hash_builder_right), |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | /// Reserves capacity for at least `additional` more elements to be inserted |
| 271 | /// in the `BiHashMap`. The collection may reserve more space to avoid |
| 272 | /// frequent reallocations. |
| 273 | /// |
| 274 | /// # Panics |
| 275 | /// |
| 276 | /// Panics if the new allocation size overflows [`usize`]. |
| 277 | /// |
| 278 | /// # Examples |
| 279 | /// |
| 280 | /// ``` |
| 281 | /// use bimap::BiHashMap; |
| 282 | /// |
| 283 | /// let mut bimap = BiHashMap::<char, i32>::new(); |
| 284 | /// bimap.reserve(10); |
| 285 | /// assert!(bimap.capacity() >= 10); |
| 286 | /// ``` |
| 287 | pub fn reserverust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]reserve().(&mut self, additional: usize) { |
| 288 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..reserverust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]reserve().(additional); |
| 289 | self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..reserverust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]reserve().(additional); |
| 290 | } |
| 291 | |
| 292 | /// Shrinks the capacity of the bimap as much as possible. It will drop |
| 293 | /// down as much as possible while maintaining the internal rules |
| 294 | /// and possibly leaving some space in accordance with the resize policy. |
| 295 | /// |
| 296 | /// # Examples |
| 297 | /// |
| 298 | /// ``` |
| 299 | /// use bimap::BiHashMap; |
| 300 | /// |
| 301 | /// let mut bimap = BiHashMap::<char, i32>::with_capacity(100); |
| 302 | /// bimap.insert('a', 1); |
| 303 | /// bimap.insert('b', 2); |
| 304 | /// assert!(bimap.capacity() >= 100); |
| 305 | /// bimap.shrink_to_fit(); |
| 306 | /// assert!(bimap.capacity() >= 2); |
| 307 | /// ``` |
| 308 | pub fn shrink_to_fitrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]shrink_to_fit().(&mut self) { |
| 309 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..shrink_to_fitrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]shrink_to_fit().(); |
| 310 | self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..shrink_to_fitrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]shrink_to_fit().(); |
| 311 | } |
| 312 | |
| 313 | /// Shrinks the capacity of the bimap with a lower limit. It will drop |
| 314 | /// down no lower than the supplied limit while maintaining the internal |
| 315 | /// rules and possibly leaving some space in accordance with the resize |
| 316 | /// policy. |
| 317 | /// |
| 318 | /// If the current capacity is less than the lower limit, this is a no-op. |
| 319 | /// |
| 320 | /// # Examples |
| 321 | /// |
| 322 | /// ``` |
| 323 | /// use bimap::BiHashMap; |
| 324 | /// |
| 325 | /// let mut bimap = BiHashMap::<char, i32>::with_capacity(100); |
| 326 | /// bimap.insert('a', 1); |
| 327 | /// bimap.insert('b', 2); |
| 328 | /// assert!(bimap.capacity() >= 100); |
| 329 | /// bimap.shrink_to(10); |
| 330 | /// assert!(bimap.capacity() >= 10); |
| 331 | /// bimap.shrink_to(0); |
| 332 | /// assert!(bimap.capacity() >= 2); |
| 333 | /// ``` |
| 334 | pub fn shrink_torust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]shrink_to().(&mut self, min_capacity: usize) { |
| 335 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..shrink_torust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]shrink_to().(min_capacity); |
| 336 | self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..shrink_torust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]shrink_to().(min_capacity); |
| 337 | } |
| 338 | |
| 339 | /// Returns a reference to the right value corresponding to the given left |
| 340 | /// value. |
| 341 | /// |
| 342 | /// The input may be any borrowed form of the bimap's left type, but `Eq` |
| 343 | /// and `Hash` on the borrowed form *must* match those for the left type. |
| 344 | /// |
| 345 | /// # Examples |
| 346 | /// |
| 347 | /// ``` |
| 348 | /// use bimap::BiHashMap; |
| 349 | /// |
| 350 | /// let mut bimap = BiHashMap::new(); |
| 351 | /// bimap.insert('a', 1); |
| 352 | /// assert_eq!(bimap.get_by_left(&'a'), Some(&1)); |
| 353 | /// assert_eq!(bimap.get_by_left(&'z'), None); |
| 354 | /// ``` |
| 355 | pub fn get_by_leftrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]get_by_left().<Q>(&self, left: &Q) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&R> |
| 356 | where |
| 357 | L: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Q>, |
| 358 | Q: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 359 | { |
| 360 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(Wrapperrust-analyzer cargo bimap 0.6.3 mem/Wrapper#::wraprust-analyzer cargo bimap 0.6.3 mem/impl#[`Wrapper<T>`]wrap().(left)).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|r| &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Deref]deref().r.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.) |
| 361 | } |
| 362 | |
| 363 | /// Returns a reference to the left value corresponding to the given right |
| 364 | /// value. |
| 365 | /// |
| 366 | /// The input may be any borrowed form of the bimap's right type, but `Eq` |
| 367 | /// and `Hash` on the borrowed form *must* match those for the right type. |
| 368 | /// |
| 369 | /// # Examples |
| 370 | /// |
| 371 | /// ``` |
| 372 | /// use bimap::BiHashMap; |
| 373 | /// |
| 374 | /// let mut bimap = BiHashMap::new(); |
| 375 | /// bimap.insert('a', 1); |
| 376 | /// assert_eq!(bimap.get_by_right(&1), Some(&'a')); |
| 377 | /// assert_eq!(bimap.get_by_right(&2), None); |
| 378 | /// ``` |
| 379 | pub fn get_by_rightrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]get_by_right().<Q>(&self, right: &Q) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&L> |
| 380 | where |
| 381 | R: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Q>, |
| 382 | Q: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 383 | { |
| 384 | self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(Wrapperrust-analyzer cargo bimap 0.6.3 mem/Wrapper#::wraprust-analyzer cargo bimap 0.6.3 mem/impl#[`Wrapper<T>`]wrap().(right)).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|l| &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Deref]deref().l.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.) |
| 385 | } |
| 386 | |
| 387 | /// Returns `true` if the bimap contains the given left value and `false` |
| 388 | /// otherwise. |
| 389 | /// |
| 390 | /// The input may be any borrowed form of the bimap's left type, but `Eq` |
| 391 | /// and `Hash` on the borrowed form *must* match those for the left type. |
| 392 | /// |
| 393 | /// # Examples |
| 394 | /// |
| 395 | /// ``` |
| 396 | /// use bimap::BiHashMap; |
| 397 | /// |
| 398 | /// let mut bimap = BiHashMap::new(); |
| 399 | /// bimap.insert('a', 1); |
| 400 | /// assert!(bimap.contains_left(&'a')); |
| 401 | /// assert!(!bimap.contains_left(&'b')); |
| 402 | /// ``` |
| 403 | pub fn contains_leftrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]contains_left().<Q>(&self, left: &Q) -> bool |
| 404 | where |
| 405 | L: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Q>, |
| 406 | Q: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 407 | { |
| 408 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..contains_keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]contains_key().(Wrapperrust-analyzer cargo bimap 0.6.3 mem/Wrapper#::wraprust-analyzer cargo bimap 0.6.3 mem/impl#[`Wrapper<T>`]wrap().(left)) |
| 409 | } |
| 410 | |
| 411 | /// Returns `true` if the map contains the given right value and `false` |
| 412 | /// otherwise. |
| 413 | /// |
| 414 | /// The input may be any borrowed form of the bimap's right type, but `Eq` |
| 415 | /// and `Hash` on the borrowed form *must* match those for the right type. |
| 416 | /// |
| 417 | /// # Examples |
| 418 | /// |
| 419 | /// ``` |
| 420 | /// use bimap::BiHashMap; |
| 421 | /// |
| 422 | /// let mut bimap = BiHashMap::new(); |
| 423 | /// bimap.insert('a', 1); |
| 424 | /// assert!(bimap.contains_right(&1)); |
| 425 | /// assert!(!bimap.contains_right(&2)); |
| 426 | /// ``` |
| 427 | pub fn contains_rightrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]contains_right().<Q>(&self, right: &Q) -> bool |
| 428 | where |
| 429 | R: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Q>, |
| 430 | Q: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 431 | { |
| 432 | self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..contains_keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]contains_key().(Wrapperrust-analyzer cargo bimap 0.6.3 mem/Wrapper#::wraprust-analyzer cargo bimap 0.6.3 mem/impl#[`Wrapper<T>`]wrap().(right)) |
| 433 | } |
| 434 | |
| 435 | /// Removes the left-right pair corresponding to the given left value. |
| 436 | /// |
| 437 | /// Returns the previous left-right pair if the map contained the left value |
| 438 | /// and `None` otherwise. |
| 439 | /// |
| 440 | /// The input may be any borrowed form of the bimap's left type, but `Eq` |
| 441 | /// and `Hash` on the borrowed form *must* match those for the left type. |
| 442 | /// |
| 443 | /// # Examples |
| 444 | /// |
| 445 | /// ``` |
| 446 | /// use bimap::BiHashMap; |
| 447 | /// |
| 448 | /// let mut bimap = BiHashMap::new(); |
| 449 | /// bimap.insert('a', 1); |
| 450 | /// bimap.insert('b', 2); |
| 451 | /// bimap.insert('c', 3); |
| 452 | /// |
| 453 | /// assert_eq!(bimap.remove_by_left(&'b'), Some(('b', 2))); |
| 454 | /// assert_eq!(bimap.remove_by_left(&'b'), None); |
| 455 | /// ``` |
| 456 | pub fn remove_by_leftrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]remove_by_left().<Q>(&mut self, left: &Q) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(L, R)> |
| 457 | where |
| 458 | L: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Q>, |
| 459 | Q: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 460 | { |
| 461 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]remove().(Wrapperrust-analyzer cargo bimap 0.6.3 mem/Wrapper#::wraprust-analyzer cargo bimap 0.6.3 mem/impl#[`Wrapper<T>`]wrap().(left)).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|right_rc| { |
| 462 | // unwrap is safe because we know right2left contains the key (it's a bimap) |
| 463 | let left_rc = self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]remove().(&right_rc).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 464 | // at this point we can safely unwrap because the other pointers are gone |
| 465 | ( |
| 466 | Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::try_unwraprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`]try_unwrap().(left_rc.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 467 | Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::try_unwraprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`]try_unwrap().(right_rc.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 468 | ) |
| 469 | }) |
| 470 | } |
| 471 | |
| 472 | /// Removes the left-right pair corresponding to the given right value. |
| 473 | /// |
| 474 | /// Returns the previous left-right pair if the map contained the right |
| 475 | /// value and `None` otherwise. |
| 476 | /// |
| 477 | /// The input may be any borrowed form of the bimap's right type, but `Eq` |
| 478 | /// and `Hash` on the borrowed form *must* match those for the right type. |
| 479 | /// |
| 480 | /// # Examples |
| 481 | /// |
| 482 | /// ``` |
| 483 | /// use bimap::BiHashMap; |
| 484 | /// |
| 485 | /// let mut bimap = BiHashMap::new(); |
| 486 | /// bimap.insert('a', 1); |
| 487 | /// bimap.insert('b', 2); |
| 488 | /// bimap.insert('c', 3); |
| 489 | /// |
| 490 | /// assert_eq!(bimap.remove_by_right(&2), Some(('b', 2))); |
| 491 | /// assert_eq!(bimap.remove_by_right(&2), None); |
| 492 | /// ``` |
| 493 | pub fn remove_by_rightrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]remove_by_right().<Q>(&mut self, right: &Q) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(L, R)> |
| 494 | where |
| 495 | R: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Q>, |
| 496 | Q: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 497 | { |
| 498 | self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]remove().(Wrapperrust-analyzer cargo bimap 0.6.3 mem/Wrapper#::wraprust-analyzer cargo bimap 0.6.3 mem/impl#[`Wrapper<T>`]wrap().(right)).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|left_rc| { |
| 499 | // unwrap is safe because we know left2right contains the key (it's a bimap) |
| 500 | let right_rc = self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]remove().(&left_rc).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 501 | // at this point we can safely unwrap because the other pointers are gone |
| 502 | ( |
| 503 | Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::try_unwraprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`]try_unwrap().(left_rc.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 504 | Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::try_unwraprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`]try_unwrap().(right_rc.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 505 | ) |
| 506 | }) |
| 507 | } |
| 508 | |
| 509 | /// Inserts the given left-right pair into the bimap. |
| 510 | /// |
| 511 | /// Returns an enum `Overwritten` representing any left-right pairs that |
| 512 | /// were overwritten by the call to `insert`. The example below details |
| 513 | /// all possible enum variants that can be returned. |
| 514 | /// |
| 515 | /// # Warnings |
| 516 | /// |
| 517 | /// Somewhat paradoxically, calling `insert()` can actually reduce the size |
| 518 | /// of the bimap! This is because of the invariant that each left value |
| 519 | /// maps to exactly one right value and vice versa. |
| 520 | /// |
| 521 | /// # Examples |
| 522 | /// |
| 523 | /// ``` |
| 524 | /// use bimap::{BiHashMap, Overwritten}; |
| 525 | /// |
| 526 | /// let mut bimap = BiHashMap::new(); |
| 527 | /// assert_eq!(bimap.len(), 0); // {} |
| 528 | /// |
| 529 | /// // no values are overwritten. |
| 530 | /// assert_eq!(bimap.insert('a', 1), Overwritten::Neither); |
| 531 | /// assert_eq!(bimap.len(), 1); // {'a' <> 1} |
| 532 | /// |
| 533 | /// // no values are overwritten. |
| 534 | /// assert_eq!(bimap.insert('b', 2), Overwritten::Neither); |
| 535 | /// assert_eq!(bimap.len(), 2); // {'a' <> 1, 'b' <> 2} |
| 536 | /// |
| 537 | /// // ('a', 1) already exists, so inserting ('a', 4) overwrites 'a', the left value. |
| 538 | /// // the previous left-right pair ('a', 1) is returned. |
| 539 | /// assert_eq!(bimap.insert('a', 4), Overwritten::Left('a', 1)); |
| 540 | /// assert_eq!(bimap.len(), 2); // {'a' <> 4, 'b' <> 2} |
| 541 | /// |
| 542 | /// // ('b', 2) already exists, so inserting ('c', 2) overwrites 2, the right value. |
| 543 | /// // the previous left-right pair ('b', 2) is returned. |
| 544 | /// assert_eq!(bimap.insert('c', 2), Overwritten::Right('b', 2)); |
| 545 | /// assert_eq!(bimap.len(), 2); // {'a' <> 1, 'c' <> 2} |
| 546 | /// |
| 547 | /// // both ('a', 4) and ('c', 2) already exist, so inserting ('a', 2) overwrites both. |
| 548 | /// // ('a', 4) has the overwritten left value ('a'), so it's the first tuple returned. |
| 549 | /// // ('c', 2) has the overwritten right value (2), so it's the second tuple returned. |
| 550 | /// assert_eq!(bimap.insert('a', 2), Overwritten::Both(('a', 4), ('c', 2))); |
| 551 | /// assert_eq!(bimap.len(), 1); // {'a' <> 2} // bimap is smaller than before! |
| 552 | /// |
| 553 | /// // ('a', 2) already exists, so inserting ('a', 2) overwrites the pair. |
| 554 | /// // the previous left-right pair ('a', 2) is returned. |
| 555 | /// assert_eq!(bimap.insert('a', 2), Overwritten::Pair('a', 2)); |
| 556 | /// assert_eq!(bimap.len(), 1); // {'a' <> 2} |
| 557 | /// ``` |
| 558 | pub fn insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().(&mut self, left: L, right: R) -> Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#<L, R> { |
| 559 | let retval = match (self.remove_by_leftrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]remove_by_left().(&left), self.remove_by_rightrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]remove_by_right().(&right)) { |
| 560 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#::Neitherrust-analyzer cargo bimap 0.6.3 Overwritten#Neither#, |
| 561 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(r_pair)) => Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#::Rightrust-analyzer cargo bimap 0.6.3 Overwritten#Right#(r_pair.0, r_pair.1), |
| 562 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(l_pair), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => { |
| 563 | // since remove_by_left() was called first, it's possible the right value was |
| 564 | // removed if a duplicate pair is being inserted |
| 565 | if l_pair.1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().right { |
| 566 | Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#::Pairrust-analyzer cargo bimap 0.6.3 Overwritten#Pair#(l_pair.0, l_pair.1) |
| 567 | } else { |
| 568 | Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#::Leftrust-analyzer cargo bimap 0.6.3 Overwritten#Left#(l_pair.0, l_pair.1) |
| 569 | } |
| 570 | } |
| 571 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(l_pair), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(r_pair)) => Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#::Bothrust-analyzer cargo bimap 0.6.3 Overwritten#Both#(l_pair, r_pair), |
| 572 | }; |
| 573 | self.insert_uncheckedrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert_unchecked().(left, right); |
| 574 | retval |
| 575 | } |
| 576 | |
| 577 | /// Inserts the given left-right pair into the bimap without overwriting any |
| 578 | /// existing values. |
| 579 | /// |
| 580 | /// Returns `Ok(())` if the pair was successfully inserted into the bimap. |
| 581 | /// If either value exists in the map, `Err((left, right)` is returned |
| 582 | /// with the attempted left-right pair and the map is unchanged. |
| 583 | /// |
| 584 | /// # Examples |
| 585 | /// |
| 586 | /// ``` |
| 587 | /// use bimap::BiHashMap; |
| 588 | /// |
| 589 | /// let mut bimap = BiHashMap::new(); |
| 590 | /// assert_eq!(bimap.insert_no_overwrite('a', 1), Ok(())); |
| 591 | /// assert_eq!(bimap.insert_no_overwrite('b', 2), Ok(())); |
| 592 | /// assert_eq!(bimap.insert_no_overwrite('a', 3), Err(('a', 3))); |
| 593 | /// assert_eq!(bimap.insert_no_overwrite('c', 2), Err(('c', 2))); |
| 594 | /// ``` |
| 595 | pub fn insert_no_overwriterust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert_no_overwrite().(&mut self, left: L, right: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), (L, R)> { |
| 596 | if self.contains_leftrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]contains_left().(&left) || self.contains_rightrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]contains_right().(&right) { |
| 597 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#((left, right)) |
| 598 | } else { |
| 599 | self.insert_uncheckedrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert_unchecked().(left, right); |
| 600 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | /// Retains only the elements specified by the predicate. |
| 605 | /// |
| 606 | /// In other words, remove all left-right pairs `(l, r)` such that `f(&l, |
| 607 | /// &r)` returns `false`. |
| 608 | /// |
| 609 | /// # Examples |
| 610 | /// |
| 611 | /// ``` |
| 612 | /// use bimap::BiHashMap; |
| 613 | /// |
| 614 | /// let mut bimap = BiHashMap::new(); |
| 615 | /// bimap.insert('a', 1); |
| 616 | /// bimap.insert('b', 2); |
| 617 | /// bimap.insert('c', 3); |
| 618 | /// bimap.retain(|&l, &r| r >= 2); |
| 619 | /// assert_eq!(bimap.len(), 2); |
| 620 | /// assert_eq!(bimap.get_by_left(&'b'), Some(&2)); |
| 621 | /// assert_eq!(bimap.get_by_left(&'c'), Some(&3)); |
| 622 | /// assert_eq!(bimap.get_by_left(&'a'), None); |
| 623 | /// ``` |
| 624 | pub fn retainrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]retain().<F>(&mut self, f: F) |
| 625 | where |
| 626 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&L, &R) -> bool, |
| 627 | { |
| 628 | let mut f = f; |
| 629 | let right2left = &mut self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left.; |
| 630 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..retainrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]retain().(|l, r| { |
| 631 | let to_retain = f(&l.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0., &r.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.); |
| 632 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().to_retain { |
| 633 | right2left.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]remove().(r); |
| 634 | } |
| 635 | to_retain |
| 636 | }); |
| 637 | } |
| 638 | |
| 639 | /// Inserts the given left-right pair into the bimap without checking if the |
| 640 | /// pair already exists. |
| 641 | fn insert_uncheckedrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert_unchecked().(&mut self, left: L, right: R) { |
| 642 | let left = Refrust-analyzer cargo bimap 0.6.3 mem/Ref#(Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T>`]new().(left)); |
| 643 | let right = Refrust-analyzer cargo bimap 0.6.3 mem/Ref#(Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T>`]new().(right)); |
| 644 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(left.clonerust-analyzer cargo bimap 0.6.3 mem/impl#[`Ref<T>`][Clone]clone().(), right.clonerust-analyzer cargo bimap 0.6.3 mem/impl#[`Ref<T>`][Clone]clone().()); |
| 645 | self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(right, left); |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | impl<L, R, LS, RS> Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# for BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 650 | where |
| 651 | L: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 652 | R: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 653 | LS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 654 | RS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 655 | { |
| 656 | fn clonerust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][Clone]clone().(&self) -> BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> { |
| 657 | let mut new_bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::with_capacity_and_hashersrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]with_capacity_and_hashers().( |
| 658 | self.capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().(), |
| 659 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..hasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]hasher().().clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 660 | self.right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left..hasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]hasher().().clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), |
| 661 | ); |
| 662 | for (l, r) in self.iterrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]iter().() { |
| 663 | new_bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().(l.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), r.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 664 | } |
| 665 | new_bimap |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | impl<L, R, LS, RS> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 670 | where |
| 671 | L: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, |
| 672 | R: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, |
| 673 | { |
| 674 | fn fmtrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 675 | struct EntryDebuggerrust-analyzer cargo bimap 0.6.3 hash/EntryDebugger#<'a, L, R> { |
| 676 | leftrust-analyzer cargo bimap 0.6.3 hash/EntryDebugger#left.: &'a L, |
| 677 | rightrust-analyzer cargo bimap 0.6.3 hash/EntryDebugger#right.: &'a R, |
| 678 | } |
| 679 | impl<'a, L, R> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for EntryDebuggerrust-analyzer cargo bimap 0.6.3 hash/EntryDebugger#<'a, L, R> |
| 680 | where |
| 681 | L: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, |
| 682 | R: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, |
| 683 | { |
| 684 | fn fmtrust-analyzer cargo bimap 0.6.3 hash/impl#[`EntryDebugger<'a, L, R>`][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 685 | self.leftrust-analyzer cargo bimap 0.6.3 hash/EntryDebugger#left..fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#fmt().(f)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 686 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, " <> ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 687 | self.rightrust-analyzer cargo bimap 0.6.3 hash/EntryDebugger#right..fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#fmt().(f) |
| 688 | } |
| 689 | } |
| 690 | f.debug_setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_set().() |
| 691 | .entriesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugSet<'a, 'b>`]entries().( |
| 692 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right. |
| 693 | .iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().() |
| 694 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(left, right)| EntryDebuggerrust-analyzer cargo bimap 0.6.3 hash/EntryDebugger# { leftrust-analyzer cargo bimap 0.6.3 hash/EntryDebugger#left., rightrust-analyzer cargo bimap 0.6.3 hash/EntryDebugger#right. }), |
| 695 | ) |
| 696 | .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugSet<'a, 'b>`]finish().() |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | impl<L, R, LS, RS> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 701 | where |
| 702 | L: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 703 | R: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 704 | LS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#, |
| 705 | RS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#, |
| 706 | { |
| 707 | fn defaultrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][Default]default().() -> BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> { |
| 708 | BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap# { |
| 709 | left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(), |
| 710 | right2leftrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#right2left.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(), |
| 711 | } |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | impl<L, R, LS, RS> Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# for BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 716 | where |
| 717 | L: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 718 | R: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 719 | LS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 720 | RS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 721 | { |
| 722 | } |
| 723 | |
| 724 | impl<L, R, LS, RS> FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#<(L, R)> for BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 725 | where |
| 726 | L: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 727 | R: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 728 | LS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#, |
| 729 | RS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#, |
| 730 | { |
| 731 | fn from_iterrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][`FromIterator<(L, R)>`]from_iter().<I>(iter: I) -> BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 732 | where |
| 733 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = (L, R)>, |
| 734 | { |
| 735 | let iter = iter.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().(); |
| 736 | let mut bimap = match iter.size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#size_hint().() { |
| 737 | (lower, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => { |
| 738 | BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::with_capacity_and_hashersrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]with_capacity_and_hashers().(lower, LS::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().(), RS::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().()) |
| 739 | } |
| 740 | (_, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(upper)) => { |
| 741 | BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::with_capacity_and_hashersrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]with_capacity_and_hashers().(upper, LS::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().(), RS::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().()) |
| 742 | } |
| 743 | }; |
| 744 | for (left, right) in iter { |
| 745 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().(left, right); |
| 746 | } |
| 747 | bimap |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | impl<'a, L, R, LS, RS> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for &'a BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 752 | where |
| 753 | L: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 754 | R: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 755 | { |
| 756 | type Itemrust-analyzer cargo bimap 0.6.3 hash/impl#[`&'a BiHashMap<L, R, LS, RS>`][IntoIterator]Item# = (&'a L, &'a R); |
| 757 | type IntoIterrust-analyzer cargo bimap 0.6.3 hash/impl#[`&'a BiHashMap<L, R, LS, RS>`][IntoIterator]IntoIter# = Iterrust-analyzer cargo bimap 0.6.3 hash/Iter#<'a, L, R>; |
| 758 | |
| 759 | fn into_iterrust-analyzer cargo bimap 0.6.3 hash/impl#[`&'a BiHashMap<L, R, LS, RS>`][IntoIterator]into_iter().(self) -> Iterrust-analyzer cargo bimap 0.6.3 hash/Iter#<'a, L, R> { |
| 760 | self.iterrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]iter().() |
| 761 | } |
| 762 | } |
| 763 | |
| 764 | impl<L, R, LS, RS> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 765 | where |
| 766 | L: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 767 | R: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 768 | { |
| 769 | type Itemrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][IntoIterator]Item# = (L, R); |
| 770 | type IntoIterrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][IntoIterator]IntoIter# = IntoIterrust-analyzer cargo bimap 0.6.3 hash/IntoIter#<L, R>; |
| 771 | |
| 772 | fn into_iterrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][IntoIterator]into_iter().(self) -> IntoIterrust-analyzer cargo bimap 0.6.3 hash/IntoIter#<L, R> { |
| 773 | IntoIterrust-analyzer cargo bimap 0.6.3 hash/IntoIter# { |
| 774 | innerrust-analyzer cargo bimap 0.6.3 hash/IntoIter#inner.: self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right..into_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][IntoIterator]into_iter().(), |
| 775 | } |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | impl<L, R, LS, RS> Extendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/Extend#<(L, R)> for BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 780 | where |
| 781 | L: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 782 | R: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 783 | LS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 784 | RS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 785 | { |
| 786 | fn extendrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][`Extend<(L, R)>`]extend().<T: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = (L, R)>>(&mut self, iter: T) { |
| 787 | iter.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#for_each().(move |(l, r)| { |
| 788 | self.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().(l, r); |
| 789 | }); |
| 790 | } |
| 791 | } |
| 792 | |
| 793 | impl<L, R, LS, RS> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 794 | where |
| 795 | L: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 796 | R: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 797 | LS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 798 | RS: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 799 | { |
| 800 | fn eqrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][`PartialEq<Self>`]eq().(&self, other: &Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][`PartialEq<Self>`]) -> bool { |
| 801 | self.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right. rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`PartialEq<Self>`]eq().other.left2rightrust-analyzer cargo bimap 0.6.3 hash/BiHashMap#left2right. |
| 802 | } |
| 803 | } |
| 804 | |
| 805 | /// An owning iterator over the left-right pairs in a `BiHashMap`. |
| 806 | pub struct IntoIterrust-analyzer cargo bimap 0.6.3 hash/IntoIter#<L, R> { |
| 807 | innerrust-analyzer cargo bimap 0.6.3 hash/IntoIter#inner.: hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::IntoIterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/IntoIter#<Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<L>, Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<R>>, |
| 808 | } |
| 809 | |
| 810 | impl<L, R> ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for IntoIterrust-analyzer cargo bimap 0.6.3 hash/IntoIter#<L, R> {} |
| 811 | |
| 812 | impl<L, R> FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for IntoIterrust-analyzer cargo bimap 0.6.3 hash/IntoIter#<L, R> {} |
| 813 | |
| 814 | impl<L, R> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for IntoIterrust-analyzer cargo bimap 0.6.3 hash/IntoIter#<L, R> { |
| 815 | type Itemrust-analyzer cargo bimap 0.6.3 hash/impl#[`IntoIter<L, R>`][Iterator]Item# = (L, R); |
| 816 | |
| 817 | fn nextrust-analyzer cargo bimap 0.6.3 hash/impl#[`IntoIter<L, R>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`IntoIter<L, R>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 818 | self.innerrust-analyzer cargo bimap 0.6.3 hash/IntoIter#inner..nextrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`IntoIter<K, V, A>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(l, r)| { |
| 819 | ( |
| 820 | Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::try_unwraprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`]try_unwrap().(l.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 821 | Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::try_unwraprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`]try_unwrap().(r.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 822 | ) |
| 823 | }) |
| 824 | } |
| 825 | |
| 826 | fn size_hintrust-analyzer cargo bimap 0.6.3 hash/impl#[`IntoIter<L, R>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 827 | self.innerrust-analyzer cargo bimap 0.6.3 hash/IntoIter#inner..size_hintrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`IntoIter<K, V, A>`][Iterator]size_hint().() |
| 828 | } |
| 829 | } |
| 830 | |
| 831 | /// An iterator over the left-right pairs in a `BiHashMap`. |
| 832 | /// |
| 833 | /// This struct is created by the [`iter`] method of `BiHashMap`. |
| 834 | /// |
| 835 | /// [`iter`]: BiHashMap::iter |
| 836 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 837 | pub struct Iterrust-analyzer cargo bimap 0.6.3 hash/Iter#<'a, L, R> { |
| 838 | innerrust-analyzer cargo bimap 0.6.3 hash/Iter#inner.: hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::Iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/Iter#<'a, Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<L>, Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<R>>, |
| 839 | } |
| 840 | |
| 841 | impl<'a, L, R> ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for Iterrust-analyzer cargo bimap 0.6.3 hash/Iter#<'a, L, R> {} |
| 842 | |
| 843 | impl<'a, L, R> FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for Iterrust-analyzer cargo bimap 0.6.3 hash/Iter#<'a, L, R> {} |
| 844 | |
| 845 | impl<'a, L, R> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Iterrust-analyzer cargo bimap 0.6.3 hash/Iter#<'a, L, R> { |
| 846 | type Itemrust-analyzer cargo bimap 0.6.3 hash/impl#[`Iter<'a, L, R>`][Iterator]Item# = (&'a L, &'a R); |
| 847 | |
| 848 | fn nextrust-analyzer cargo bimap 0.6.3 hash/impl#[`Iter<'a, L, R>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`Iter<'a, L, R>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 849 | self.innerrust-analyzer cargo bimap 0.6.3 hash/Iter#inner..nextrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Iter<'a, K, V>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(l, r)| (&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Deref]deref().l.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0., &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Deref]deref().r.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.)) |
| 850 | } |
| 851 | |
| 852 | fn size_hintrust-analyzer cargo bimap 0.6.3 hash/impl#[`Iter<'a, L, R>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 853 | self.innerrust-analyzer cargo bimap 0.6.3 hash/Iter#inner..size_hintrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Iter<'a, K, V>`][Iterator]size_hint().() |
| 854 | } |
| 855 | } |
| 856 | |
| 857 | /// An iterator over the left values in a `BiHashMap`. |
| 858 | /// |
| 859 | /// This struct is created by the [`left_values`] method of `BiHashMap`. |
| 860 | /// |
| 861 | /// [`left_values`]: BiHashMap::left_values |
| 862 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 863 | pub struct LeftValuesrust-analyzer cargo bimap 0.6.3 hash/LeftValues#<'a, L, R> { |
| 864 | innerrust-analyzer cargo bimap 0.6.3 hash/LeftValues#inner.: hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::Iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/Iter#<'a, Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<L>, Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<R>>, |
| 865 | } |
| 866 | |
| 867 | impl<'a, L, R> ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for LeftValuesrust-analyzer cargo bimap 0.6.3 hash/LeftValues#<'a, L, R> {} |
| 868 | |
| 869 | impl<'a, L, R> FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for LeftValuesrust-analyzer cargo bimap 0.6.3 hash/LeftValues#<'a, L, R> {} |
| 870 | |
| 871 | impl<'a, L, R> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for LeftValuesrust-analyzer cargo bimap 0.6.3 hash/LeftValues#<'a, L, R> { |
| 872 | type Itemrust-analyzer cargo bimap 0.6.3 hash/impl#[`LeftValues<'a, L, R>`][Iterator]Item# = &'a L; |
| 873 | |
| 874 | fn nextrust-analyzer cargo bimap 0.6.3 hash/impl#[`LeftValues<'a, L, R>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`LeftValues<'a, L, R>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 875 | self.innerrust-analyzer cargo bimap 0.6.3 hash/LeftValues#inner..nextrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Iter<'a, K, V>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(l, _)| &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Deref]deref().l.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.) |
| 876 | } |
| 877 | |
| 878 | fn size_hintrust-analyzer cargo bimap 0.6.3 hash/impl#[`LeftValues<'a, L, R>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 879 | self.innerrust-analyzer cargo bimap 0.6.3 hash/LeftValues#inner..size_hintrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Iter<'a, K, V>`][Iterator]size_hint().() |
| 880 | } |
| 881 | } |
| 882 | |
| 883 | /// An iterator over the right values in a `BiHashMap`. |
| 884 | /// |
| 885 | /// This struct is created by the [`right_values`] method of `BiHashMap`. |
| 886 | /// |
| 887 | /// [`right_values`]: BiHashMap::right_values |
| 888 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 889 | pub struct RightValuesrust-analyzer cargo bimap 0.6.3 hash/RightValues#<'a, L, R> { |
| 890 | innerrust-analyzer cargo bimap 0.6.3 hash/RightValues#inner.: hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::Iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/Iter#<'a, Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<R>, Refrust-analyzer cargo bimap 0.6.3 mem/Ref#<L>>, |
| 891 | } |
| 892 | |
| 893 | impl<'a, L, R> ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for RightValuesrust-analyzer cargo bimap 0.6.3 hash/RightValues#<'a, L, R> {} |
| 894 | |
| 895 | impl<'a, L, R> FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for RightValuesrust-analyzer cargo bimap 0.6.3 hash/RightValues#<'a, L, R> {} |
| 896 | |
| 897 | impl<'a, L, R> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for RightValuesrust-analyzer cargo bimap 0.6.3 hash/RightValues#<'a, L, R> { |
| 898 | type Itemrust-analyzer cargo bimap 0.6.3 hash/impl#[`RightValues<'a, L, R>`][Iterator]Item# = &'a R; |
| 899 | |
| 900 | fn nextrust-analyzer cargo bimap 0.6.3 hash/impl#[`RightValues<'a, L, R>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo bimap 0.6.3 hash/impl#[`RightValues<'a, L, R>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 901 | self.innerrust-analyzer cargo bimap 0.6.3 hash/RightValues#inner..nextrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Iter<'a, K, V>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(r, _)| &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Deref]deref().r.0rust-analyzer cargo bimap 0.6.3 mem/Ref#0.) |
| 902 | } |
| 903 | |
| 904 | fn size_hintrust-analyzer cargo bimap 0.6.3 hash/impl#[`RightValues<'a, L, R>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 905 | self.innerrust-analyzer cargo bimap 0.6.3 hash/RightValues#inner..size_hintrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Iter<'a, K, V>`][Iterator]size_hint().() |
| 906 | } |
| 907 | } |
| 908 | |
| 909 | // safe because internal Rcs are not exposed by the api and the reference counts |
| 910 | // only change in methods with &mut self |
| 911 | unsafe impl<L, R, LS, RS> Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# for BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 912 | where |
| 913 | L: Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#, |
| 914 | R: Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#, |
| 915 | LS: Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#, |
| 916 | RS: Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#, |
| 917 | { |
| 918 | } |
| 919 | unsafe impl<L, R, LS, RS> Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# for BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<L, R, LS, RS> |
| 920 | where |
| 921 | L: Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#, |
| 922 | R: Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#, |
| 923 | LS: Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#, |
| 924 | RS: Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#, |
| 925 | { |
| 926 | } |
| 927 | |
| 928 | #[cfg(test)] |
| 929 | mod testsrust-analyzer cargo bimap 0.6.3 hash/tests/ { |
| 930 | use superrust-analyzer cargo bimap 0.6.3 hash/::*; |
| 931 | |
| 932 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 933 | fn clonerust-analyzer cargo bimap 0.6.3 hash/tests/clone().() { |
| 934 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 935 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 1); |
| 936 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 937 | let bimap2 = bimap.clonerust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][Clone]clone().(); |
| 938 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap, bimap2); |
| 939 | } |
| 940 | |
| 941 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 942 | fn deep_clonerust-analyzer cargo bimap 0.6.3 hash/tests/deep_clone().() { |
| 943 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 944 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 1); |
| 945 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 946 | let mut bimap2 = bimap.clonerust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][Clone]clone().(); |
| 947 | |
| 948 | // would panic if clone() didn't deep clone |
| 949 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 5); |
| 950 | bimap2.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 12); |
| 951 | bimap2.remove_by_leftrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]remove_by_left().(&'a'); |
| 952 | bimap.remove_by_rightrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]remove_by_right().(&2); |
| 953 | } |
| 954 | |
| 955 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 956 | fn debugrust-analyzer cargo bimap 0.6.3 hash/tests/debug().() { |
| 957 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 958 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("{}", formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", bimap)); |
| 959 | |
| 960 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 1); |
| 961 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("{'a' <> 1}", formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", bimap)); |
| 962 | |
| 963 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 964 | let expected1 = "{'a' <> 1, 'b' <> 2}"; |
| 965 | let expected2 = "{'b' <> 2, 'a' <> 1}"; |
| 966 | let formatted = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", bimap); |
| 967 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(formatted == expected1 || formatted == expected2); |
| 968 | } |
| 969 | |
| 970 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 971 | fn defaultrust-analyzer cargo bimap 0.6.3 hash/tests/default().() { |
| 972 | let _ = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::<char, i32>::defaultrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][Default]default().(); |
| 973 | } |
| 974 | |
| 975 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 976 | fn eqrust-analyzer cargo bimap 0.6.3 hash/tests/eq().() { |
| 977 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 978 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap, bimap); |
| 979 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 1); |
| 980 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap, bimap); |
| 981 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 982 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap, bimap); |
| 983 | |
| 984 | let mut bimap2 = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 985 | assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(bimap, bimap2); |
| 986 | bimap2.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 1); |
| 987 | assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(bimap, bimap2); |
| 988 | bimap2.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 989 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap, bimap2); |
| 990 | bimap2.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('c', 3); |
| 991 | assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(bimap, bimap2); |
| 992 | } |
| 993 | |
| 994 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 995 | fn from_iterrust-analyzer cargo bimap 0.6.3 hash/tests/from_iter().() { |
| 996 | let bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::from_iterrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][`FromIterator<(L, R)>`]from_iter().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 997 | ('a', 1), |
| 998 | ('b', 2), |
| 999 | ('c', 3), |
| 1000 | ('b', 2), |
| 1001 | ('a', 4), |
| 1002 | ('b', 3), |
| 1003 | ]); |
| 1004 | let mut bimap2 = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1005 | bimap2.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 4); |
| 1006 | bimap2.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 3); |
| 1007 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap, bimap2); |
| 1008 | } |
| 1009 | |
| 1010 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1011 | fn into_iterrust-analyzer cargo bimap 0.6.3 hash/tests/into_iter().() { |
| 1012 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1013 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 3); |
| 1014 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 1015 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('c', 1); |
| 1016 | let mut pairs = bimap.into_iterrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 1017 | pairs.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().(); |
| 1018 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pairs, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![('a', 3), ('b', 2), ('c', 1)]); |
| 1019 | } |
| 1020 | |
| 1021 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1022 | fn into_iter_refrust-analyzer cargo bimap 0.6.3 hash/tests/into_iter_ref().() { |
| 1023 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1024 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 3); |
| 1025 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 1026 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('c', 1); |
| 1027 | let mut pairs = (&bimap).into_iterrust-analyzer cargo bimap 0.6.3 hash/impl#[`&'a BiHashMap<L, R, LS, RS>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 1028 | pairs.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().(); |
| 1029 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pairs, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(&'a', &3), (&'b', &2), (&'c', &1)]); |
| 1030 | } |
| 1031 | |
| 1032 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1033 | fn extendrust-analyzer cargo bimap 0.6.3 hash/tests/extend().() { |
| 1034 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1035 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 3); |
| 1036 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 1037 | bimap.extendrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`][`Extend<(L, R)>`]extend().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![('c', 3), ('b', 1), ('a', 4)]); |
| 1038 | let mut bimap2 = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1039 | bimap2.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 4); |
| 1040 | bimap2.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 1); |
| 1041 | bimap2.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('c', 3); |
| 1042 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap, bimap2); |
| 1043 | } |
| 1044 | |
| 1045 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1046 | fn iterrust-analyzer cargo bimap 0.6.3 hash/tests/iter().() { |
| 1047 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1048 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 1); |
| 1049 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 1050 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('c', 3); |
| 1051 | let mut pairs = bimap.iterrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(c, i)| (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().i)).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 1052 | pairs.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().(); |
| 1053 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pairs, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![('a', 1), ('b', 2), ('c', 3)]); |
| 1054 | } |
| 1055 | |
| 1056 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1057 | fn left_valuesrust-analyzer cargo bimap 0.6.3 hash/tests/left_values().() { |
| 1058 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1059 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 3); |
| 1060 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 1061 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('c', 1); |
| 1062 | let mut left_values = bimap.left_valuesrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]left_values().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 1063 | left_values.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().(); |
| 1064 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left_values, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!['a', 'b', 'c']) |
| 1065 | } |
| 1066 | |
| 1067 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1068 | fn right_valuesrust-analyzer cargo bimap 0.6.3 hash/tests/right_values().() { |
| 1069 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1070 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 3); |
| 1071 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 1072 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('c', 1); |
| 1073 | let mut right_values = bimap.right_valuesrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]right_values().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 1074 | right_values.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().(); |
| 1075 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right_values, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]) |
| 1076 | } |
| 1077 | |
| 1078 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1079 | fn capacityrust-analyzer cargo bimap 0.6.3 hash/tests/capacity().() { |
| 1080 | let bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::<char, i32>::with_capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]with_capacity().(10); |
| 1081 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().() >= 10); |
| 1082 | } |
| 1083 | |
| 1084 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1085 | fn with_hashersrust-analyzer cargo bimap 0.6.3 hash/tests/with_hashers().() { |
| 1086 | let s_left = hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::RandomStaterust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/RandomState#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/impl#[RandomState]new().(); |
| 1087 | let s_right = hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::RandomStaterust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/RandomState#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/impl#[RandomState]new().(); |
| 1088 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::<char, i32>::with_hashersrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]with_hashers().(s_left, s_right); |
| 1089 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 42); |
| 1090 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&'a'), bimap.get_by_rightrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]get_by_right().(&42)); |
| 1091 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&42), bimap.get_by_leftrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]get_by_left().(&'a')); |
| 1092 | } |
| 1093 | |
| 1094 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1095 | fn reserverust-analyzer cargo bimap 0.6.3 hash/tests/reserve().() { |
| 1096 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::<char, i32>::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1097 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().()); |
| 1098 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 0); |
| 1099 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().(), 0); |
| 1100 | |
| 1101 | bimap.reserverust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]reserve().(10); |
| 1102 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().()); |
| 1103 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 0); |
| 1104 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().() >= 10); |
| 1105 | } |
| 1106 | |
| 1107 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1108 | fn shrink_to_fitrust-analyzer cargo bimap 0.6.3 hash/tests/shrink_to_fit().() { |
| 1109 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::<char, i32>::with_capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]with_capacity().(100); |
| 1110 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().()); |
| 1111 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 0); |
| 1112 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().() >= 100); |
| 1113 | |
| 1114 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 1); |
| 1115 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 1116 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().bimap.is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().()); |
| 1117 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 2); |
| 1118 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().() >= 100); |
| 1119 | |
| 1120 | bimap.shrink_to_fitrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]shrink_to_fit().(); |
| 1121 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().bimap.is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().()); |
| 1122 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 2); |
| 1123 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().() >= 2); |
| 1124 | } |
| 1125 | |
| 1126 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1127 | fn shrink_torust-analyzer cargo bimap 0.6.3 hash/tests/shrink_to().() { |
| 1128 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::<char, i32>::with_capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]with_capacity().(100); |
| 1129 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().()); |
| 1130 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 0); |
| 1131 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().() >= 100); |
| 1132 | |
| 1133 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 1); |
| 1134 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 1135 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().bimap.is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().()); |
| 1136 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 2); |
| 1137 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().() >= 100); |
| 1138 | |
| 1139 | bimap.shrink_torust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]shrink_to().(10); |
| 1140 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().bimap.is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().()); |
| 1141 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 2); |
| 1142 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().() >= 10); |
| 1143 | |
| 1144 | bimap.shrink_torust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]shrink_to().(0); |
| 1145 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().bimap.is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().()); |
| 1146 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 2); |
| 1147 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.capacityrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]capacity().() >= 2); |
| 1148 | } |
| 1149 | |
| 1150 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1151 | fn clearrust-analyzer cargo bimap 0.6.3 hash/tests/clear().() { |
| 1152 | let mut bimap = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![('a', 1)].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<_, _>>(); |
| 1153 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 1); |
| 1154 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().bimap.is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().()); |
| 1155 | |
| 1156 | bimap.clearrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]clear().(); |
| 1157 | |
| 1158 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 0); |
| 1159 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.is_emptyrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]is_empty().()); |
| 1160 | } |
| 1161 | |
| 1162 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1163 | fn get_containsrust-analyzer cargo bimap 0.6.3 hash/tests/get_contains().() { |
| 1164 | let bimap = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![('a', 1)].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#<_, _>>(); |
| 1165 | |
| 1166 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.get_by_leftrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]get_by_left().(&'a'), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&1)); |
| 1167 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.contains_leftrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]contains_left().(&'a')); |
| 1168 | |
| 1169 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.get_by_leftrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]get_by_left().(&'b'), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1170 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().bimap.contains_leftrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]contains_left().(&'b')); |
| 1171 | |
| 1172 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.get_by_rightrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]get_by_right().(&1), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&'a')); |
| 1173 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.contains_rightrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]contains_right().(&1)); |
| 1174 | |
| 1175 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.get_by_rightrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]get_by_right().(&2), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1176 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().bimap.contains_rightrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]contains_right().(&2)); |
| 1177 | } |
| 1178 | |
| 1179 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1180 | fn insertrust-analyzer cargo bimap 0.6.3 hash/tests/insert().() { |
| 1181 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1182 | |
| 1183 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 1), Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#::Neitherrust-analyzer cargo bimap 0.6.3 Overwritten#Neither#); |
| 1184 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 2), Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#::Leftrust-analyzer cargo bimap 0.6.3 Overwritten#Left#('a', 1)); |
| 1185 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2), Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#::Rightrust-analyzer cargo bimap 0.6.3 Overwritten#Right#('a', 2)); |
| 1186 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2), Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#::Pairrust-analyzer cargo bimap 0.6.3 Overwritten#Pair#('b', 2)); |
| 1187 | |
| 1188 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('c', 3), Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#::Neitherrust-analyzer cargo bimap 0.6.3 Overwritten#Neither#); |
| 1189 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 3), Overwrittenrust-analyzer cargo bimap 0.6.3 Overwritten#::Bothrust-analyzer cargo bimap 0.6.3 Overwritten#Both#(('b', 2), ('c', 3))); |
| 1190 | } |
| 1191 | |
| 1192 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1193 | fn insert_no_overwriterust-analyzer cargo bimap 0.6.3 hash/tests/insert_no_overwrite().() { |
| 1194 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1195 | |
| 1196 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.insert_no_overwriterust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert_no_overwrite().('a', 1).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1197 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.insert_no_overwriterust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert_no_overwrite().('a', 2).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1198 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bimap.insert_no_overwriterust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert_no_overwrite().('b', 1).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1199 | } |
| 1200 | |
| 1201 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1202 | fn retain_calls_f_oncerust-analyzer cargo bimap 0.6.3 hash/tests/retain_calls_f_once().() { |
| 1203 | let mut bimap = BiHashMaprust-analyzer cargo bimap 0.6.3 hash/BiHashMap#::newrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R>`]new().(); |
| 1204 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('a', 1); |
| 1205 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('b', 2); |
| 1206 | bimap.insertrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]insert().('c', 3); |
| 1207 | |
| 1208 | // retain one element |
| 1209 | let mut i = 0; |
| 1210 | bimap.retainrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]retain().(|_l, _r| { |
| 1211 | i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().1; |
| 1212 | i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]le().1 |
| 1213 | }); |
| 1214 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bimap.lenrust-analyzer cargo bimap 0.6.3 hash/impl#[`BiHashMap<L, R, LS, RS>`]len().(), 1); |
| 1215 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(i, 3); |
| 1216 | } |
| 1217 | } |