about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorPiotr Czarnecki <pioczarn@gmail.com>2016-03-06 12:24:18 +0100
committerPiotr Czarnecki <pioczarn@gmail.com>2016-03-06 12:24:18 +0100
commitef874310f2c11671e96fd700aceb9dcbc44db983 (patch)
treecb4232936148fe6588ad05017a51ecda397120f0 /src/libstd
parentd67cf45d2222fdde16d935dead18a8be4b080060 (diff)
downloadrust-ef874310f2c11671e96fd700aceb9dcbc44db983.tar.gz
rust-ef874310f2c11671e96fd700aceb9dcbc44db983.zip
fix Recover::replace
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/collections/hash/map.rs9
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!()
+                }
             }
         }
     }