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);
if let Some(location) = self.nodes.location(key, hash) {
Some(unsafe {
self.nodes
.node_at_unchecked_mut(location)
.value_mut_unchecked()
})
} else {
None
}
let location = self.nodes.location(key, hash)?;
Some(unsafe {
self.nodes
.node_at_unchecked_mut(location)
.value_mut_unchecked()
})
}
/// Removes the given key from the map. Returns the current value if it existed, or [`None`]