diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 6f044958618..8fb703e8fb8 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1668,8 +1668,13 @@ impl<K, S, Q: ?Sized> super::Recover<Q> for HashMap<K, (), S> InternalEntry::Occupied { mut elem } => { Some(mem::replace(elem.read_mut().0, key)) } - _ => { - None + other => { + if let Some(Vacant(vacant)) = other.into_entry(key) { + vacant.insert(()); + None + } else { + unreachable!() + } } } } |
