| 1 | //! Opt-in access to the experimental raw entry API. |
| 2 | //! |
| 3 | //! This module is designed to mimic the raw entry API of [`HashMap`][std::collections::hash_map], |
| 4 | //! matching its unstable state as of Rust 1.75. See the tracking issue |
| 5 | //! [rust#56167](https://github.com/rust-lang/rust/issues/56167) for more details. |
| 6 | //! |
| 7 | //! The trait [`RawEntryApiV1`] and the `_v1` suffix on its methods are meant to insulate this for |
| 8 | //! the future, in case later breaking changes are needed. If the standard library stabilizes its |
| 9 | //! `hash_raw_entry` feature (or some replacement), matching *inherent* methods will be added to |
| 10 | //! `OrderMap` without such an opt-in trait. |
| 11 | |
| 12 | use craterust-analyzer cargo ordermap 1.2.0 crate/::{Equivalentrust-analyzer cargo equivalent 1.0.2 Equivalent#, OrderMaprust-analyzer cargo ordermap 1.2.0 map/OrderMap#}; |
| 13 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/; |
| 14 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core 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#}; |
| 15 | use indexmaprust-analyzer cargo indexmap 2.14.0 crate/::maprust-analyzer cargo indexmap 2.14.0 map/::RawEntryApiV1rust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/RawEntryApiV1# as _; |
| 16 | use indexmaprust-analyzer cargo indexmap 2.14.0 crate/::maprust-analyzer cargo indexmap 2.14.0 map/::raw_entry_v1rust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/ as ixrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/; |
| 17 | |
| 18 | #[cfg(doc)] |
| 19 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#; |
| 20 | |
| 21 | /// Opt-in access to the experimental raw entry API. |
| 22 | /// |
| 23 | /// See the [`raw_entry_v1`][self] module documentation for more information. |
| 24 | #[expect(private_bounds)] |
| 25 | pub trait RawEntryApiV1rust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryApiV1#<K, V, S>: Sealedrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/Sealed# { |
| 26 | /// Creates a raw immutable entry builder for the [`OrderMap`]. |
| 27 | /// |
| 28 | /// Raw entries provide the lowest level of control for searching and |
| 29 | /// manipulating a map. They must be manually initialized with a hash and |
| 30 | /// then manually searched. |
| 31 | /// |
| 32 | /// This is useful for |
| 33 | /// * Hash memoization |
| 34 | /// * Using a search key that doesn't work with the [`Equivalent`] trait |
| 35 | /// * Using custom comparison logic without newtype wrappers |
| 36 | /// |
| 37 | /// Unless you are in such a situation, higher-level and more foolproof APIs like |
| 38 | /// [`get`][OrderMap::get] should be preferred. |
| 39 | /// |
| 40 | /// Immutable raw entries have very limited use; you might instead want |
| 41 | /// [`raw_entry_mut_v1`][Self::raw_entry_mut_v1]. |
| 42 | /// |
| 43 | /// # Examples |
| 44 | /// |
| 45 | /// ``` |
| 46 | /// use core::hash::BuildHasher; |
| 47 | /// use ordermap::map::{OrderMap, RawEntryApiV1}; |
| 48 | /// |
| 49 | /// let mut map = OrderMap::new(); |
| 50 | /// map.extend([("a", 100), ("b", 200), ("c", 300)]); |
| 51 | /// |
| 52 | /// for k in ["a", "b", "c", "d", "e", "f"] { |
| 53 | /// let hash = map.hasher().hash_one(k); |
| 54 | /// let i = map.get_index_of(k); |
| 55 | /// let v = map.get(k); |
| 56 | /// let kv = map.get_key_value(k); |
| 57 | /// let ikv = map.get_full(k); |
| 58 | /// |
| 59 | /// println!("Key: {} and value: {:?}", k, v); |
| 60 | /// |
| 61 | /// assert_eq!(map.raw_entry_v1().from_key(k), kv); |
| 62 | /// assert_eq!(map.raw_entry_v1().from_hash(hash, |q| *q == k), kv); |
| 63 | /// assert_eq!(map.raw_entry_v1().from_key_hashed_nocheck(hash, k), kv); |
| 64 | /// assert_eq!(map.raw_entry_v1().from_hash_full(hash, |q| *q == k), ikv); |
| 65 | /// assert_eq!(map.raw_entry_v1().index_from_hash(hash, |q| *q == k), i); |
| 66 | /// } |
| 67 | /// ``` |
| 68 | fn raw_entry_v1rust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryApiV1#raw_entry_v1().(&self) -> RawEntryBuilderrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#<'_, K, V, S>; |
| 69 | |
| 70 | /// Creates a raw entry builder for the [`OrderMap`]. |
| 71 | /// |
| 72 | /// Raw entries provide the lowest level of control for searching and |
| 73 | /// manipulating a map. They must be manually initialized with a hash and |
| 74 | /// then manually searched. After this, insertions into a vacant entry |
| 75 | /// still require an owned key to be provided. |
| 76 | /// |
| 77 | /// Raw entries are useful for such exotic situations as: |
| 78 | /// |
| 79 | /// * Hash memoization |
| 80 | /// * Deferring the creation of an owned key until it is known to be required |
| 81 | /// * Using a search key that doesn't work with the [`Equivalent`] trait |
| 82 | /// * Using custom comparison logic without newtype wrappers |
| 83 | /// |
| 84 | /// Because raw entries provide much more low-level control, it's much easier |
| 85 | /// to put the `OrderMap` into an inconsistent state which, while memory-safe, |
| 86 | /// will cause the map to produce seemingly random results. Higher-level and more |
| 87 | /// foolproof APIs like [`entry`][OrderMap::entry] should be preferred when possible. |
| 88 | /// |
| 89 | /// Raw entries give mutable access to the keys. This must not be used |
| 90 | /// to modify how the key would compare or hash, as the map will not re-evaluate |
| 91 | /// where the key should go, meaning the keys may become "lost" if their |
| 92 | /// location does not reflect their state. For instance, if you change a key |
| 93 | /// so that the map now contains keys which compare equal, search may start |
| 94 | /// acting erratically, with two keys randomly masking each other. Implementations |
| 95 | /// are free to assume this doesn't happen (within the limits of memory-safety). |
| 96 | /// |
| 97 | /// # Examples |
| 98 | /// |
| 99 | /// ``` |
| 100 | /// use core::hash::BuildHasher; |
| 101 | /// use ordermap::map::{OrderMap, RawEntryApiV1}; |
| 102 | /// use ordermap::map::raw_entry_v1::RawEntryMut; |
| 103 | /// |
| 104 | /// let mut map = OrderMap::new(); |
| 105 | /// map.extend([("a", 100), ("b", 200), ("c", 300)]); |
| 106 | /// |
| 107 | /// // Existing key (insert and update) |
| 108 | /// match map.raw_entry_mut_v1().from_key("a") { |
| 109 | /// RawEntryMut::Vacant(_) => unreachable!(), |
| 110 | /// RawEntryMut::Occupied(mut view) => { |
| 111 | /// assert_eq!(view.index(), 0); |
| 112 | /// assert_eq!(view.get(), &100); |
| 113 | /// let v = view.get_mut(); |
| 114 | /// let new_v = (*v) * 10; |
| 115 | /// *v = new_v; |
| 116 | /// assert_eq!(view.insert(1111), 1000); |
| 117 | /// } |
| 118 | /// } |
| 119 | /// |
| 120 | /// assert_eq!(map["a"], 1111); |
| 121 | /// assert_eq!(map.len(), 3); |
| 122 | /// |
| 123 | /// // Existing key (take) |
| 124 | /// let hash = map.hasher().hash_one("c"); |
| 125 | /// match map.raw_entry_mut_v1().from_key_hashed_nocheck(hash, "c") { |
| 126 | /// RawEntryMut::Vacant(_) => unreachable!(), |
| 127 | /// RawEntryMut::Occupied(view) => { |
| 128 | /// assert_eq!(view.index(), 2); |
| 129 | /// assert_eq!(view.remove_entry(), ("c", 300)); |
| 130 | /// } |
| 131 | /// } |
| 132 | /// assert_eq!(map.raw_entry_v1().from_key("c"), None); |
| 133 | /// assert_eq!(map.len(), 2); |
| 134 | /// |
| 135 | /// // Nonexistent key (insert and update) |
| 136 | /// let key = "d"; |
| 137 | /// let hash = map.hasher().hash_one(key); |
| 138 | /// match map.raw_entry_mut_v1().from_hash(hash, |q| *q == key) { |
| 139 | /// RawEntryMut::Occupied(_) => unreachable!(), |
| 140 | /// RawEntryMut::Vacant(view) => { |
| 141 | /// assert_eq!(view.index(), 2); |
| 142 | /// let (k, value) = view.insert("d", 4000); |
| 143 | /// assert_eq!((*k, *value), ("d", 4000)); |
| 144 | /// *value = 40000; |
| 145 | /// } |
| 146 | /// } |
| 147 | /// assert_eq!(map["d"], 40000); |
| 148 | /// assert_eq!(map.len(), 3); |
| 149 | /// |
| 150 | /// match map.raw_entry_mut_v1().from_hash(hash, |q| *q == key) { |
| 151 | /// RawEntryMut::Vacant(_) => unreachable!(), |
| 152 | /// RawEntryMut::Occupied(view) => { |
| 153 | /// assert_eq!(view.index(), 2); |
| 154 | /// assert_eq!(view.swap_remove_entry(), ("d", 40000)); |
| 155 | /// } |
| 156 | /// } |
| 157 | /// assert_eq!(map.get("d"), None); |
| 158 | /// assert_eq!(map.len(), 2); |
| 159 | /// ``` |
| 160 | fn raw_entry_mut_v1rust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryApiV1#raw_entry_mut_v1().(&mut self) -> RawEntryBuilderMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilderMut#<'_, K, V, S>; |
| 161 | } |
| 162 | |
| 163 | impl<K, V, S> RawEntryApiV1rust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryApiV1#<K, V, S> for OrderMaprust-analyzer cargo ordermap 1.2.0 map/OrderMap#<K, V, S> { |
| 164 | fn raw_entry_v1rust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`OrderMap<K, V, S>`][`RawEntryApiV1<K, V, S>`]raw_entry_v1().(&self) -> RawEntryBuilderrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#<'_, K, V, S> { |
| 165 | RawEntryBuilderrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder# { |
| 166 | innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#inner.: self.innerrust-analyzer cargo ordermap 1.2.0 map/OrderMap#inner..raw_entry_v1rust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`IndexMap<K, V, S>`][`RawEntryApiV1<K, V, S>`]raw_entry_v1().(), |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | fn raw_entry_mut_v1rust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`OrderMap<K, V, S>`][`RawEntryApiV1<K, V, S>`]raw_entry_mut_v1().(&mut self) -> RawEntryBuilderMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilderMut#<'_, K, V, S> { |
| 171 | RawEntryBuilderMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilderMut# { |
| 172 | innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilderMut#inner.: self.innerrust-analyzer cargo ordermap 1.2.0 map/OrderMap#inner..raw_entry_mut_v1rust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`IndexMap<K, V, S>`][`RawEntryApiV1<K, V, S>`]raw_entry_mut_v1().(), |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | /// A builder for computing where in an [`OrderMap`] a key-value pair would be stored. |
| 178 | /// |
| 179 | /// This `struct` is created by the [`OrderMap::raw_entry_v1`] method, provided by the |
| 180 | /// [`RawEntryApiV1`] trait. See its documentation for more. |
| 181 | pub struct RawEntryBuilderrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#<'a, K, V, S> { |
| 182 | innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#inner.: ixrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/::RawEntryBuilderrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/RawEntryBuilder#<'a, K, V, S>, |
| 183 | } |
| 184 | |
| 185 | impl<K, V, S> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for RawEntryBuilderrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#<'_, K, V, S> { |
| 186 | fn fmtrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryBuilder<'_, K, V, S>`][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 187 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("RawEntryBuilder").finish_non_exhaustiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish_non_exhaustive().() |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | impl<'a, K, V, S> RawEntryBuilderrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#<'a, K, V, S> { |
| 192 | /// Access an entry by key. |
| 193 | pub fn from_keyrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryBuilder<'a, K, V, S>`]from_key().<Q>(self, key: &Q) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&'a K, &'a V)> |
| 194 | where |
| 195 | S: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 196 | Q: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Equivalentrust-analyzer cargo equivalent 1.0.2 Equivalent#<K>, |
| 197 | { |
| 198 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#inner..from_keyrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawEntryBuilder<'a, K, V, S>`]from_key().(key) |
| 199 | } |
| 200 | |
| 201 | /// Access an entry by a key and its hash. |
| 202 | pub fn from_key_hashed_nocheckrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryBuilder<'a, K, V, S>`]from_key_hashed_nocheck().<Q>(self, hash: u64, key: &Q) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&'a K, &'a V)> |
| 203 | where |
| 204 | Q: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Equivalentrust-analyzer cargo equivalent 1.0.2 Equivalent#<K>, |
| 205 | { |
| 206 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#inner..from_key_hashed_nocheckrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawEntryBuilder<'a, K, V, S>`]from_key_hashed_nocheck().(hash, key) |
| 207 | } |
| 208 | |
| 209 | /// Access an entry by hash. |
| 210 | pub fn from_hashrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryBuilder<'a, K, V, S>`]from_hash().<F>(self, hash: u64, is_match: F) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&'a K, &'a V)> |
| 211 | where |
| 212 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&K) -> bool, |
| 213 | { |
| 214 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#inner..from_hashrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawEntryBuilder<'a, K, V, S>`]from_hash().(hash, is_match) |
| 215 | } |
| 216 | |
| 217 | /// Access an entry by hash, including its index. |
| 218 | pub fn from_hash_fullrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryBuilder<'a, K, V, S>`]from_hash_full().<F>(self, hash: u64, is_match: F) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, &'a K, &'a V)> |
| 219 | where |
| 220 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&K) -> bool, |
| 221 | { |
| 222 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#inner..from_hash_fullrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawEntryBuilder<'a, K, V, S>`]from_hash_full().(hash, is_match) |
| 223 | } |
| 224 | |
| 225 | /// Access the index of an entry by hash. |
| 226 | pub fn index_from_hashrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryBuilder<'a, K, V, S>`]index_from_hash().<F>(self, hash: u64, is_match: F) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize> |
| 227 | where |
| 228 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&K) -> bool, |
| 229 | { |
| 230 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilder#inner..index_from_hashrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawEntryBuilder<'a, K, V, S>`]index_from_hash().(hash, is_match) |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | /// A builder for computing where in an [`OrderMap`] a key-value pair would be stored. |
| 235 | /// |
| 236 | /// This `struct` is created by the [`OrderMap::raw_entry_mut_v1`] method, provided by the |
| 237 | /// [`RawEntryApiV1`] trait. See its documentation for more. |
| 238 | pub struct RawEntryBuilderMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilderMut#<'a, K, V, S> { |
| 239 | innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilderMut#inner.: ixrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/::RawEntryBuilderMutrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/RawEntryBuilderMut#<'a, K, V, S>, |
| 240 | } |
| 241 | |
| 242 | impl<K, V, S> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for RawEntryBuilderMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilderMut#<'_, K, V, S> { |
| 243 | fn fmtrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryBuilderMut<'_, K, V, S>`][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 244 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("RawEntryBuilderMut").finish_non_exhaustiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish_non_exhaustive().() |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | impl<'a, K, V, S> RawEntryBuilderMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilderMut#<'a, K, V, S> { |
| 249 | /// Access an entry by key. |
| 250 | pub fn from_keyrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryBuilderMut<'a, K, V, S>`]from_key().<Q>(self, key: &Q) -> RawEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#<'a, K, V, S> |
| 251 | where |
| 252 | S: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 253 | Q: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Equivalentrust-analyzer cargo equivalent 1.0.2 Equivalent#<K>, |
| 254 | { |
| 255 | RawEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#::newrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]new().(self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilderMut#inner..from_keyrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawEntryBuilderMut<'a, K, V, S>`]from_key().(key)) |
| 256 | } |
| 257 | |
| 258 | /// Access an entry by a key and its hash. |
| 259 | pub fn from_key_hashed_nocheckrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryBuilderMut<'a, K, V, S>`]from_key_hashed_nocheck().<Q>(self, hash: u64, key: &Q) -> RawEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#<'a, K, V, S> |
| 260 | where |
| 261 | Q: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Equivalentrust-analyzer cargo equivalent 1.0.2 Equivalent#<K>, |
| 262 | { |
| 263 | RawEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#::newrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]new().(self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilderMut#inner..from_key_hashed_nocheckrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawEntryBuilderMut<'a, K, V, S>`]from_key_hashed_nocheck().(hash, key)) |
| 264 | } |
| 265 | |
| 266 | /// Access an entry by hash. |
| 267 | pub fn from_hashrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryBuilderMut<'a, K, V, S>`]from_hash().<F>(self, hash: u64, is_match: F) -> RawEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#<'a, K, V, S> |
| 268 | where |
| 269 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&K) -> bool, |
| 270 | { |
| 271 | RawEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#::newrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]new().(self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryBuilderMut#inner..from_hashrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawEntryBuilderMut<'a, K, V, S>`]from_hash().(hash, is_match)) |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | /// Raw entry for an existing key-value pair or a vacant location to |
| 276 | /// insert one. |
| 277 | pub enum RawEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#<'a, K, V, S> { |
| 278 | /// Existing slot with equivalent key. |
| 279 | Occupiedrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Occupied#(RawOccupiedEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#<'a, K, V, S>), |
| 280 | /// Vacant slot (no equivalent key in the map). |
| 281 | Vacantrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Vacant#(RawVacantEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut#<'a, K, V, S>), |
| 282 | } |
| 283 | |
| 284 | impl<K: fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, V: fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, S> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for RawEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#<'_, K, V, S> { |
| 285 | fn fmtrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'_, K, V, S>`][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 286 | let mut tuple = f.debug_tuplerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_tuple().("RawEntryMut"); |
| 287 | match self { |
| 288 | Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'_, K, V, S>`][Debug]::Vacantrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Vacant#(v) => tuple.fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugTuple<'a, 'b>`]field().(v), |
| 289 | Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'_, K, V, S>`][Debug]::Occupiedrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Occupied#(o) => tuple.fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugTuple<'a, 'b>`]field().(o), |
| 290 | }; |
| 291 | tuple.finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugTuple<'a, 'b>`]finish().() |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | impl<'a, K, V, S> RawEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#<'a, K, V, S> { |
| 296 | fn newrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]new().(entry: ixrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/::RawEntryMutrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/RawEntryMut#<'a, K, V, S>) -> Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`] { |
| 297 | match entry { |
| 298 | ixrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/::RawEntryMutrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/RawEntryMut#::Occupiedrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/RawEntryMut#Occupied#(inner) => Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]::Occupiedrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Occupied#(RawOccupiedEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut# { innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner. }), |
| 299 | ixrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/::RawEntryMutrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/RawEntryMut#::Vacantrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/RawEntryMut#Vacant#(inner) => Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]::Vacantrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Vacant#(RawVacantEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut# { innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut#inner. }), |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | /// Return the index where the key-value pair exists or may be inserted. |
| 304 | #[inline] |
| 305 | pub fn indexrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]index().(&self) -> usize { |
| 306 | match self { |
| 307 | Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]::Occupiedrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Occupied#(entry) => entry.indexrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]index().(), |
| 308 | Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]::Vacantrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Vacant#(entry) => entry.indexrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]index().(), |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | /// Inserts the given default key and value in the entry if it is vacant and returns mutable |
| 313 | /// references to them. Otherwise mutable references to an already existent pair are returned. |
| 314 | pub fn or_insertrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]or_insert().(self, default_key: K, default_value: V) -> (&'a mut K, &'a mut V) |
| 315 | where |
| 316 | K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 317 | S: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 318 | { |
| 319 | match self { |
| 320 | Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]::Occupiedrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Occupied#(entry) => entry.into_key_value_mutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]into_key_value_mut().(), |
| 321 | Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]::Vacantrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Vacant#(entry) => entry.insertrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]insert().(default_key, default_value), |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | /// Inserts the result of the `call` function in the entry if it is vacant and returns mutable |
| 326 | /// references to them. Otherwise mutable references to an already existent pair are returned. |
| 327 | pub fn or_insert_withrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]or_insert_with().<F>(self, call: F) -> (&'a mut K, &'a mut V) |
| 328 | where |
| 329 | F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#() -> (K, V), |
| 330 | K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 331 | S: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 332 | { |
| 333 | match self { |
| 334 | Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]::Occupiedrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Occupied#(entry) => entry.into_key_value_mutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]into_key_value_mut().(), |
| 335 | Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]::Vacantrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Vacant#(entry) => { |
| 336 | let (key, value) = call(); |
| 337 | entry.insertrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]insert().(key, value) |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | /// Modifies the entry if it is occupied. |
| 343 | pub fn and_modifyrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]and_modify().<F>(mut self, f: F) -> Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`] |
| 344 | where |
| 345 | F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#(&mut K, &mut V), |
| 346 | { |
| 347 | if let Selfrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawEntryMut<'a, K, V, S>`]::Occupiedrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawEntryMut#Occupied#(entry) = &mut self { |
| 348 | let (k, v) = entry.get_key_value_mutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]get_key_value_mut().(); |
| 349 | f(k, v); |
| 350 | } |
| 351 | self |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | /// A raw view into an occupied entry in an [`OrderMap`]. |
| 356 | /// It is part of the [`RawEntryMut`] enum. |
| 357 | pub struct RawOccupiedEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#<'a, K, V, S> { |
| 358 | innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner.: ixrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/::RawOccupiedEntryMutrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/RawOccupiedEntryMut#<'a, K, V, S>, |
| 359 | } |
| 360 | |
| 361 | impl<K: fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, V: fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, S> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for RawOccupiedEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#<'_, K, V, S> { |
| 362 | fn fmtrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'_, K, V, S>`][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 363 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("RawOccupiedEntryMut") |
| 364 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("key", self.keyrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]key().()) |
| 365 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("value", self.getrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]get().()) |
| 366 | .finish_non_exhaustiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish_non_exhaustive().() |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | impl<'a, K, V, S> RawOccupiedEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#<'a, K, V, S> { |
| 371 | /// Return the index of the key-value pair |
| 372 | #[inline] |
| 373 | pub fn indexrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]index().(&self) -> usize { |
| 374 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..indexrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]index().() |
| 375 | } |
| 376 | |
| 377 | /// Gets a reference to the entry's key in the map. |
| 378 | /// |
| 379 | /// Note that this is not the key that was used to find the entry. There may be an observable |
| 380 | /// difference if the key type has any distinguishing features outside of `Hash` and `Eq`, like |
| 381 | /// extra fields or the memory address of an allocation. |
| 382 | pub fn keyrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]key().(&self) -> &K { |
| 383 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..keyrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]key().() |
| 384 | } |
| 385 | |
| 386 | /// Gets a mutable reference to the entry's key in the map. |
| 387 | /// |
| 388 | /// Note that this is not the key that was used to find the entry. There may be an observable |
| 389 | /// difference if the key type has any distinguishing features outside of `Hash` and `Eq`, like |
| 390 | /// extra fields or the memory address of an allocation. |
| 391 | pub fn key_mutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]key_mut().(&mut self) -> &mut K { |
| 392 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..key_mutrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]key_mut().() |
| 393 | } |
| 394 | |
| 395 | /// Converts into a mutable reference to the entry's key in the map, |
| 396 | /// with a lifetime bound to the map itself. |
| 397 | /// |
| 398 | /// Note that this is not the key that was used to find the entry. There may be an observable |
| 399 | /// difference if the key type has any distinguishing features outside of `Hash` and `Eq`, like |
| 400 | /// extra fields or the memory address of an allocation. |
| 401 | pub fn into_keyrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]into_key().(self) -> &'a mut K { |
| 402 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..into_keyrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]into_key().() |
| 403 | } |
| 404 | |
| 405 | /// Gets a reference to the entry's value in the map. |
| 406 | pub fn getrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]get().(&self) -> &V { |
| 407 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..getrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]get().() |
| 408 | } |
| 409 | |
| 410 | /// Gets a mutable reference to the entry's value in the map. |
| 411 | /// |
| 412 | /// If you need a reference which may outlive the destruction of the |
| 413 | /// [`RawEntryMut`] value, see [`into_mut`][Self::into_mut]. |
| 414 | pub fn get_mutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]get_mut().(&mut self) -> &mut V { |
| 415 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..get_mutrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]get_mut().() |
| 416 | } |
| 417 | |
| 418 | /// Converts into a mutable reference to the entry's value in the map, |
| 419 | /// with a lifetime bound to the map itself. |
| 420 | pub fn into_mutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]into_mut().(self) -> &'a mut V { |
| 421 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..into_mutrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]into_mut().() |
| 422 | } |
| 423 | |
| 424 | /// Gets a reference to the entry's key and value in the map. |
| 425 | pub fn get_key_valuerust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]get_key_value().(&self) -> (&K, &V) { |
| 426 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..get_key_valuerust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]get_key_value().() |
| 427 | } |
| 428 | |
| 429 | /// Gets a reference to the entry's key and value in the map. |
| 430 | pub fn get_key_value_mutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]get_key_value_mut().(&mut self) -> (&mut K, &mut V) { |
| 431 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..get_key_value_mutrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]get_key_value_mut().() |
| 432 | } |
| 433 | |
| 434 | /// Converts into a mutable reference to the entry's key and value in the map, |
| 435 | /// with a lifetime bound to the map itself. |
| 436 | pub fn into_key_value_mutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]into_key_value_mut().(self) -> (&'a mut K, &'a mut V) { |
| 437 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..into_key_value_mutrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]into_key_value_mut().() |
| 438 | } |
| 439 | |
| 440 | /// Sets the value of the entry, and returns the entry's old value. |
| 441 | pub fn insertrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]insert().(&mut self, value: V) -> V { |
| 442 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..insertrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]insert().(value) |
| 443 | } |
| 444 | |
| 445 | /// Sets the key of the entry, and returns the entry's old key. |
| 446 | pub fn insert_keyrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]insert_key().(&mut self, key: K) -> K { |
| 447 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..insert_keyrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]insert_key().(key) |
| 448 | } |
| 449 | |
| 450 | /// Remove the key, value pair stored in the map for this entry, and return the value. |
| 451 | /// |
| 452 | /// **NOTE:** This is equivalent to indexmap's |
| 453 | /// [`RawOccupiedEntryMut::shift_remove`][ix::RawOccupiedEntryMut::shift_remove], and |
| 454 | /// like [`Vec::remove`], the pair is removed by shifting all of the |
| 455 | /// elements that follow it, preserving their relative order. |
| 456 | /// **This perturbs the index of all of those elements!** |
| 457 | /// |
| 458 | /// Computes in **O(n)** time (average). |
| 459 | pub fn removerust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]remove().(self) -> V { |
| 460 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..shift_removerust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]shift_remove().() |
| 461 | } |
| 462 | |
| 463 | /// Remove the key, value pair stored in the map for this entry, and return the value. |
| 464 | /// |
| 465 | /// Like [`Vec::swap_remove`], the pair is removed by swapping it with |
| 466 | /// the last element of the map and popping it off. |
| 467 | /// **This perturbs the position of what used to be the last element!** |
| 468 | /// |
| 469 | /// Computes in **O(1)** time (average). |
| 470 | pub fn swap_removerust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]swap_remove().(self) -> V { |
| 471 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..swap_removerust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]swap_remove().() |
| 472 | } |
| 473 | |
| 474 | /// Remove and return the key, value pair stored in the map for this entry |
| 475 | /// |
| 476 | /// **NOTE:** This is equivalent to indexmap's |
| 477 | /// [`RawOccupiedEntryMut::shift_remove_entry`][ix::RawOccupiedEntryMut::shift_remove_entry], and |
| 478 | /// like [`Vec::remove`], the pair is removed by shifting all of the |
| 479 | /// elements that follow it, preserving their relative order. |
| 480 | /// **This perturbs the index of all of those elements!** |
| 481 | /// |
| 482 | /// Computes in **O(n)** time (average). |
| 483 | pub fn remove_entryrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]remove_entry().(self) -> (K, V) { |
| 484 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..shift_remove_entryrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]shift_remove_entry().() |
| 485 | } |
| 486 | |
| 487 | /// Remove and return the key, value pair stored in the map for this entry |
| 488 | /// |
| 489 | /// Like [`Vec::swap_remove`], the pair is removed by swapping it with |
| 490 | /// the last element of the map and popping it off. |
| 491 | /// **This perturbs the position of what used to be the last element!** |
| 492 | /// |
| 493 | /// Computes in **O(1)** time (average). |
| 494 | pub fn swap_remove_entryrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]swap_remove_entry().(self) -> (K, V) { |
| 495 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..swap_remove_entryrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]swap_remove_entry().() |
| 496 | } |
| 497 | |
| 498 | /// Moves the position of the entry to a new index |
| 499 | /// by shifting all other entries in-between. |
| 500 | /// |
| 501 | /// This is equivalent to [`OrderMap::move_index`] |
| 502 | /// coming `from` the current [`.index()`][Self::index]. |
| 503 | /// |
| 504 | /// * If `self.index() < to`, the other pairs will shift down while the targeted pair moves up. |
| 505 | /// * If `self.index() > to`, the other pairs will shift up while the targeted pair moves down. |
| 506 | /// |
| 507 | /// ***Panics*** if `to` is out of bounds. |
| 508 | /// |
| 509 | /// Computes in **O(n)** time (average). |
| 510 | #[track_caller] |
| 511 | pub fn move_indexrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]move_index().(self, to: usize) { |
| 512 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..move_indexrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]move_index().(to); |
| 513 | } |
| 514 | |
| 515 | /// Swaps the position of entry with another. |
| 516 | /// |
| 517 | /// This is equivalent to [`OrderMap::swap_indices`] |
| 518 | /// with the current [`.index()`][Self::index] as one of the two being swapped. |
| 519 | /// |
| 520 | /// ***Panics*** if the `other` index is out of bounds. |
| 521 | /// |
| 522 | /// Computes in **O(1)** time (average). |
| 523 | #[track_caller] |
| 524 | pub fn swap_indicesrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]swap_indices().(self, other: usize) { |
| 525 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawOccupiedEntryMut#inner..swap_indicesrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawOccupiedEntryMut<'a, K, V, S>`]swap_indices().(other); |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | /// A view into a vacant raw entry in an [`OrderMap`]. |
| 530 | /// It is part of the [`RawEntryMut`] enum. |
| 531 | pub struct RawVacantEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut#<'a, K, V, S> { |
| 532 | innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut#inner.: ixrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/::RawVacantEntryMutrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/RawVacantEntryMut#<'a, K, V, S>, |
| 533 | } |
| 534 | |
| 535 | impl<K, V, S> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for RawVacantEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut#<'_, K, V, S> { |
| 536 | fn fmtrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'_, K, V, S>`][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 537 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("RawVacantEntryMut").finish_non_exhaustiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish_non_exhaustive().() |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | impl<'a, K, V, S> RawVacantEntryMutrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut#<'a, K, V, S> { |
| 542 | /// Return the index where a key-value pair may be inserted. |
| 543 | pub fn indexrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]index().(&self) -> usize { |
| 544 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut#inner..indexrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]index().() |
| 545 | } |
| 546 | |
| 547 | /// Inserts the given key and value into the map, |
| 548 | /// and returns mutable references to them. |
| 549 | pub fn insertrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]insert().(self, key: K, value: V) -> (&'a mut K, &'a mut V) |
| 550 | where |
| 551 | K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 552 | S: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 553 | { |
| 554 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut#inner..insertrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]insert().(key, value) |
| 555 | } |
| 556 | |
| 557 | /// Inserts the given key and value into the map with the provided hash, |
| 558 | /// and returns mutable references to them. |
| 559 | pub fn insert_hashed_nocheckrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]insert_hashed_nocheck().(self, hash: u64, key: K, value: V) -> (&'a mut K, &'a mut V) { |
| 560 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut#inner..insert_hashed_nocheckrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]insert_hashed_nocheck().(hash, key, value) |
| 561 | } |
| 562 | |
| 563 | /// Inserts the given key and value into the map at the given index, |
| 564 | /// shifting others to the right, and returns mutable references to them. |
| 565 | /// |
| 566 | /// ***Panics*** if `index` is out of bounds. |
| 567 | /// |
| 568 | /// Computes in **O(n)** time (average). |
| 569 | #[track_caller] |
| 570 | pub fn shift_insertrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]shift_insert().(self, index: usize, key: K, value: V) -> (&'a mut K, &'a mut V) |
| 571 | where |
| 572 | K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, |
| 573 | S: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 574 | { |
| 575 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut#inner..shift_insertrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]shift_insert().(index, key, value) |
| 576 | } |
| 577 | |
| 578 | /// Inserts the given key and value into the map with the provided hash |
| 579 | /// at the given index, and returns mutable references to them. |
| 580 | /// |
| 581 | /// ***Panics*** if `index` is out of bounds. |
| 582 | /// |
| 583 | /// Computes in **O(n)** time (average). |
| 584 | #[track_caller] |
| 585 | pub fn shift_insert_hashed_nocheckrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]shift_insert_hashed_nocheck().( |
| 586 | self, |
| 587 | index: usize, |
| 588 | hash: u64, |
| 589 | key: K, |
| 590 | value: V, |
| 591 | ) -> (&'a mut K, &'a mut V) { |
| 592 | self.innerrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/RawVacantEntryMut#inner. |
| 593 | .shift_insert_hashed_nocheckrust-analyzer cargo indexmap 2.14.0 map/raw_entry_v1/impl#[`RawVacantEntryMut<'a, K, V, S>`]shift_insert_hashed_nocheck().(index, hash, key, value) |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | trait Sealedrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/Sealed# {} |
| 598 | |
| 599 | impl<K, V, S> Sealedrust-analyzer cargo ordermap 1.2.0 map/raw_entry_v1/Sealed# for OrderMaprust-analyzer cargo ordermap 1.2.0 map/OrderMap#<K, V, S> {} |