| 1 | use superrust-analyzer cargo ordermap 1.2.0 map/::{Entryrust-analyzer cargo ordermap 1.2.0 map/entry/Entry#, Equivalentrust-analyzer cargo equivalent 1.0.2 Equivalent#, IndexedEntryrust-analyzer cargo ordermap 1.2.0 map/entry/IndexedEntry#, IterMut2rust-analyzer cargo indexmap 2.14.0 map/iter/IterMut2#, OccupiedEntryrust-analyzer cargo ordermap 1.2.0 map/entry/OccupiedEntry#, OrderMaprust-analyzer cargo ordermap 1.2.0 map/OrderMap#, VacantEntryrust-analyzer cargo ordermap 1.2.0 map/entry/VacantEntry#}; |
| 2 | 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#}; |
| 3 | use indexmaprust-analyzer cargo indexmap 2.14.0 crate/::maprust-analyzer cargo indexmap 2.14.0 map/::MutableEntryKeyrust-analyzer cargo indexmap 2.14.0 map/mutable/MutableEntryKey# as _; |
| 4 | use indexmaprust-analyzer cargo indexmap 2.14.0 crate/::maprust-analyzer cargo indexmap 2.14.0 map/::MutableKeysrust-analyzer cargo indexmap 2.14.0 map/mutable/MutableKeys# as _; |
| 5 | |
| 6 | /// Opt-in mutable access to [`OrderMap`] keys. |
| 7 | /// |
| 8 | /// These methods expose `&mut K`, mutable references to the key as it is stored |
| 9 | /// in the map. |
| 10 | /// You are allowed to modify the keys in the map **if the modification |
| 11 | /// does not change the key's hash and equality**. |
| 12 | /// |
| 13 | /// If keys are modified erroneously, you can no longer look them up. |
| 14 | /// This is sound (memory safe) but a logical error hazard (just like |
| 15 | /// implementing `PartialEq`, `Eq`, or `Hash` incorrectly would be). |
| 16 | /// |
| 17 | /// `use` this trait to enable its methods for `OrderMap`. |
| 18 | /// |
| 19 | /// This trait is sealed and cannot be implemented for types outside this crate. |
| 20 | #[expect(private_bounds)] |
| 21 | pub trait MutableKeysrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#: Sealedrust-analyzer cargo ordermap 1.2.0 map/mutable/Sealed# { |
| 22 | type Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Key#; |
| 23 | type Valuerust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Value#; |
| 24 | |
| 25 | /// Return item index, mutable reference to key and value |
| 26 | /// |
| 27 | /// Computes in **O(1)** time (average). |
| 28 | fn get_full_mut2rust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#get_full_mut2().<Q>(&mut self, key: &Q) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, &mut Self::Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Key#, &mut Self::Valuerust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Value#)> |
| 29 | where |
| 30 | 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#<Self::Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Key#>; |
| 31 | |
| 32 | /// Return mutable reference to key and value at an index. |
| 33 | /// |
| 34 | /// Valid indices are `0 <= index < self.len()`. |
| 35 | /// |
| 36 | /// Computes in **O(1)** time. |
| 37 | fn get_index_mut2rust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#get_index_mut2().(&mut self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&mut Self::Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Key#, &mut Self::Valuerust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Value#)>; |
| 38 | |
| 39 | /// Return an iterator over the key-value pairs of the map, in their order |
| 40 | fn iter_mut2rust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#iter_mut2().(&mut self) -> IterMut2rust-analyzer cargo indexmap 2.14.0 map/iter/IterMut2#<'_, Self::Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Key#, Self::Valuerust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Value#>; |
| 41 | |
| 42 | /// Scan through each key-value pair in the map and keep those where the |
| 43 | /// closure `keep` returns `true`. |
| 44 | /// |
| 45 | /// The elements are visited in order, and remaining elements keep their |
| 46 | /// order. |
| 47 | /// |
| 48 | /// Computes in **O(n)** time (average). |
| 49 | fn retain2rust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#retain2().<F>(&mut self, keep: F) |
| 50 | where |
| 51 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&mut Self::Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Key#, &mut Self::Valuerust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Value#) -> bool; |
| 52 | } |
| 53 | |
| 54 | /// Opt-in mutable access to [`OrderMap`] keys. |
| 55 | /// |
| 56 | /// See [`MutableKeys`] for more information. |
| 57 | impl<K, V, S> MutableKeysrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys# for OrderMaprust-analyzer cargo ordermap 1.2.0 map/OrderMap#<K, V, S> |
| 58 | where |
| 59 | S: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 60 | { |
| 61 | type Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OrderMap<K, V, S>`][MutableKeys]Key# = K; |
| 62 | type Valuerust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OrderMap<K, V, S>`][MutableKeys]Value# = V; |
| 63 | |
| 64 | fn get_full_mut2rust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OrderMap<K, V, S>`][MutableKeys]get_full_mut2().<Q>(&mut self, key: &Q) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, &mut K, &mut V)> |
| 65 | where |
| 66 | 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>, |
| 67 | { |
| 68 | self.innerrust-analyzer cargo ordermap 1.2.0 map/OrderMap#inner..get_full_mut2rust-analyzer cargo indexmap 2.14.0 map/mutable/impl#[`IndexMap<K, V, S>`][MutableKeys]get_full_mut2().(key) |
| 69 | } |
| 70 | |
| 71 | fn get_index_mut2rust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OrderMap<K, V, S>`][MutableKeys]get_index_mut2().(&mut self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&mut K, &mut V)> { |
| 72 | self.innerrust-analyzer cargo ordermap 1.2.0 map/OrderMap#inner..get_index_mut2rust-analyzer cargo indexmap 2.14.0 map/mutable/impl#[`IndexMap<K, V, S>`][MutableKeys]get_index_mut2().(index) |
| 73 | } |
| 74 | |
| 75 | fn iter_mut2rust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OrderMap<K, V, S>`][MutableKeys]iter_mut2().(&mut self) -> IterMut2rust-analyzer cargo indexmap 2.14.0 map/iter/IterMut2#<'_, Selfrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OrderMap<K, V, S>`][MutableKeys]::Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Key#, Selfrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OrderMap<K, V, S>`][MutableKeys]::Valuerust-analyzer cargo ordermap 1.2.0 map/mutable/MutableKeys#Value#> { |
| 76 | self.innerrust-analyzer cargo ordermap 1.2.0 map/OrderMap#inner..iter_mut2rust-analyzer cargo indexmap 2.14.0 map/mutable/impl#[`IndexMap<K, V, S>`][MutableKeys]iter_mut2().() |
| 77 | } |
| 78 | |
| 79 | fn retain2rust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OrderMap<K, V, S>`][MutableKeys]retain2().<F>(&mut self, keep: F) |
| 80 | where |
| 81 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&mut K, &mut V) -> bool, |
| 82 | { |
| 83 | self.innerrust-analyzer cargo ordermap 1.2.0 map/OrderMap#inner..retain2rust-analyzer cargo indexmap 2.14.0 map/mutable/impl#[`IndexMap<K, V, S>`][MutableKeys]retain2().(keep); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /// Opt-in mutable access to [`Entry`] keys. |
| 88 | /// |
| 89 | /// These methods expose `&mut K`, mutable references to the key as it is stored |
| 90 | /// in the map. |
| 91 | /// You are allowed to modify the keys in the map **if the modification |
| 92 | /// does not change the key's hash and equality**. |
| 93 | /// |
| 94 | /// If keys are modified erroneously, you can no longer look them up. |
| 95 | /// This is sound (memory safe) but a logical error hazard (just like |
| 96 | /// implementing `PartialEq`, `Eq`, or `Hash` incorrectly would be). |
| 97 | /// |
| 98 | /// `use` this trait to enable its methods for `Entry`. |
| 99 | /// |
| 100 | /// This trait is sealed and cannot be implemented for types outside this crate. |
| 101 | #[expect(private_bounds)] |
| 102 | pub trait MutableEntryKeyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey#: Sealedrust-analyzer cargo ordermap 1.2.0 map/mutable/Sealed# { |
| 103 | type Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey#Key#; |
| 104 | |
| 105 | /// Gets a mutable reference to the entry's key, either within the map if occupied, |
| 106 | /// or else the new key that was used to find the entry. |
| 107 | fn key_mutrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey#key_mut().(&mut self) -> &mut Self::Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey#Key#; |
| 108 | } |
| 109 | |
| 110 | /// Opt-in mutable access to [`Entry`] keys. |
| 111 | /// |
| 112 | /// See [`MutableEntryKey`] for more information. |
| 113 | impl<K, V> MutableEntryKeyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey# for Entryrust-analyzer cargo ordermap 1.2.0 map/entry/Entry#<'_, K, V> { |
| 114 | type Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`Entry<'_, K, V>`][MutableEntryKey]Key# = K; |
| 115 | fn key_mutrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`Entry<'_, K, V>`][MutableEntryKey]key_mut().(&mut self) -> &mut Selfrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`Entry<'_, K, V>`][MutableEntryKey]::Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey#Key# { |
| 116 | match self { |
| 117 | Entryrust-analyzer cargo ordermap 1.2.0 map/entry/Entry#::Occupiedrust-analyzer cargo ordermap 1.2.0 map/entry/Entry#Occupied#(e) => e.key_mutrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OccupiedEntry<'_, K, V>`][MutableEntryKey]key_mut().(), |
| 118 | Entryrust-analyzer cargo ordermap 1.2.0 map/entry/Entry#::Vacantrust-analyzer cargo ordermap 1.2.0 map/entry/Entry#Vacant#(e) => e.key_mutrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`VacantEntry<'_, K, V>`][MutableEntryKey]key_mut().(), |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | /// Opt-in mutable access to [`OccupiedEntry`] keys. |
| 124 | /// |
| 125 | /// See [`MutableEntryKey`] for more information. |
| 126 | impl<K, V> MutableEntryKeyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey# for OccupiedEntryrust-analyzer cargo ordermap 1.2.0 map/entry/OccupiedEntry#<'_, K, V> { |
| 127 | type Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OccupiedEntry<'_, K, V>`][MutableEntryKey]Key# = K; |
| 128 | fn key_mutrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OccupiedEntry<'_, K, V>`][MutableEntryKey]key_mut().(&mut self) -> &mut Selfrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`OccupiedEntry<'_, K, V>`][MutableEntryKey]::Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey#Key# { |
| 129 | self.innerrust-analyzer cargo ordermap 1.2.0 map/entry/OccupiedEntry#inner..key_mutrust-analyzer cargo indexmap 2.14.0 map/mutable/impl#[`OccupiedEntry<'_, K, V>`][MutableEntryKey]key_mut().() |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | /// Opt-in mutable access to [`VacantEntry`] keys. |
| 134 | /// |
| 135 | /// See [`MutableEntryKey`] for more information. |
| 136 | impl<K, V> MutableEntryKeyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey# for VacantEntryrust-analyzer cargo ordermap 1.2.0 map/entry/VacantEntry#<'_, K, V> { |
| 137 | type Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`VacantEntry<'_, K, V>`][MutableEntryKey]Key# = K; |
| 138 | fn key_mutrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`VacantEntry<'_, K, V>`][MutableEntryKey]key_mut().(&mut self) -> &mut Selfrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`VacantEntry<'_, K, V>`][MutableEntryKey]::Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey#Key# { |
| 139 | self.innerrust-analyzer cargo ordermap 1.2.0 map/entry/VacantEntry#inner..key_mutrust-analyzer cargo indexmap 2.14.0 map/mutable/impl#[`VacantEntry<'_, K, V>`][MutableEntryKey]key_mut().() |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | /// Opt-in mutable access to [`IndexedEntry`] keys. |
| 144 | /// |
| 145 | /// See [`MutableEntryKey`] for more information. |
| 146 | impl<K, V> MutableEntryKeyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey# for IndexedEntryrust-analyzer cargo ordermap 1.2.0 map/entry/IndexedEntry#<'_, K, V> { |
| 147 | type Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`IndexedEntry<'_, K, V>`][MutableEntryKey]Key# = K; |
| 148 | fn key_mutrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`IndexedEntry<'_, K, V>`][MutableEntryKey]key_mut().(&mut self) -> &mut Selfrust-analyzer cargo ordermap 1.2.0 map/mutable/impl#[`IndexedEntry<'_, K, V>`][MutableEntryKey]::Keyrust-analyzer cargo ordermap 1.2.0 map/mutable/MutableEntryKey#Key# { |
| 149 | self.innerrust-analyzer cargo ordermap 1.2.0 map/entry/IndexedEntry#inner..key_mutrust-analyzer cargo indexmap 2.14.0 map/mutable/impl#[`IndexedEntry<'_, K, V>`][MutableEntryKey]key_mut().() |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | trait Sealedrust-analyzer cargo ordermap 1.2.0 map/mutable/Sealed# {} |
| 154 | |
| 155 | impl<K, V, S> Sealedrust-analyzer cargo ordermap 1.2.0 map/mutable/Sealed# for OrderMaprust-analyzer cargo ordermap 1.2.0 map/OrderMap#<K, V, S> {} |
| 156 | impl<K, V> Sealedrust-analyzer cargo ordermap 1.2.0 map/mutable/Sealed# for Entryrust-analyzer cargo ordermap 1.2.0 map/entry/Entry#<'_, K, V> {} |
| 157 | impl<K, V> Sealedrust-analyzer cargo ordermap 1.2.0 map/mutable/Sealed# for OccupiedEntryrust-analyzer cargo ordermap 1.2.0 map/entry/OccupiedEntry#<'_, K, V> {} |
| 158 | impl<K, V> Sealedrust-analyzer cargo ordermap 1.2.0 map/mutable/Sealed# for VacantEntryrust-analyzer cargo ordermap 1.2.0 map/entry/VacantEntry#<'_, K, V> {} |
| 159 | impl<K, V> Sealedrust-analyzer cargo ordermap 1.2.0 map/mutable/Sealed# for IndexedEntryrust-analyzer cargo ordermap 1.2.0 map/entry/IndexedEntry#<'_, K, V> {} |