Skip to content

Commit ef87431

Browse files
committed
fix Recover::replace
1 parent d67cf45 commit ef87431

File tree

1 file changed

+7
-2
lines changed
  • src/libstd/collections/hash

1 file changed

+7
-2
lines changed

src/libstd/collections/hash/map.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,8 +1668,13 @@ impl<K, S, Q: ?Sized> super::Recover<Q> for HashMap<K, (), S>
16681668
InternalEntry::Occupied { mut elem } => {
16691669
Some(mem::replace(elem.read_mut().0, key))
16701670
}
1671-
_ => {
1672-
None
1671+
other => {
1672+
if let Some(Vacant(vacant)) = other.into_entry(key) {
1673+
vacant.insert(());
1674+
None
1675+
} else {
1676+
unreachable!()
1677+
}
16731678
}
16741679
}
16751680
}

0 commit comments

Comments
 (0)