We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 48a98b7 commit cd4c1a5Copy full SHA for cd4c1a5
src/map.rs
@@ -902,6 +902,22 @@ where
902
}
903
904
905
+ /// Return references to the key-value pair stored for `key`,
906
+ /// if it is present, else `None`.
907
+ ///
908
+ /// Computes in **O(1)** time (average).
909
+ pub fn get_key_value_mut<Q>(&mut self, key: &Q) -> Option<(&K, &mut V)>
910
+ where
911
+ Q: ?Sized + Hash + Equivalent<K>,
912
+ {
913
+ if let Some(i) = self.get_index_of(key) {
914
+ let entry = &mut self.as_entries_mut()[i];
915
+ Some((&entry.key, &mut entry.value))
916
+ } else {
917
+ None
918
+ }
919
920
+
921
pub fn get_full_mut<Q>(&mut self, key: &Q) -> Option<(usize, &K, &mut V)>
922
where
923
Q: ?Sized + Hash + Equivalent<K>,
0 commit comments