From ef874310f2c11671e96fd700aceb9dcbc44db983 Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Sun, 6 Mar 2016 12:24:18 +0100 Subject: [PATCH] fix Recover::replace --- src/libstd/collections/hash/map.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 6f04495861858..8fb703e8fb830 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1668,8 +1668,13 @@ impl super::Recover for HashMap 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!() + } } } }