Simplify get_mut implementation

This commit is contained in:
Gwilym Inzani 2023-05-09 21:37:52 +01:00
parent 917163f88b
commit 9205ba1d0d

View file

@ -401,15 +401,12 @@ where
{ {
let hash = self.hash(key); let hash = self.hash(key);
if let Some(location) = self.nodes.location(key, hash) { let location = self.nodes.location(key, hash)?;
Some(unsafe { Some(unsafe {
self.nodes self.nodes
.node_at_unchecked_mut(location) .node_at_unchecked_mut(location)
.value_mut_unchecked() .value_mut_unchecked()
}) })
} else {
None
}
} }
/// Removes the given key from the map. Returns the current value if it existed, or [`None`] /// Removes the given key from the map. Returns the current value if it existed, or [`None`]