about summary refs log tree commit diff
path: root/src/liballoc/collections
diff options
context:
space:
mode:
Diffstat (limited to 'src/liballoc/collections')
-rw-r--r--src/liballoc/collections/btree/map.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs
index 682e7c53084..38fa3d73624 100644
--- a/src/liballoc/collections/btree/map.rs
+++ b/src/liballoc/collections/btree/map.rs
@@ -1544,19 +1544,19 @@ impl<K, V> IntoIterator for BTreeMap<K, V> {
     type IntoIter = IntoIter<K, V>;
 
     fn into_iter(self) -> IntoIter<K, V> {
-        let me = ManuallyDrop::new(self);
-        if me.root.is_none() {
-            return IntoIter { front: None, back: None, length: 0 };
-        }
-
-        let root1 = unsafe { unwrap_unchecked(ptr::read(&me.root)).into_ref() };
-        let root2 = unsafe { unwrap_unchecked(ptr::read(&me.root)).into_ref() };
-        let len = me.length;
-
-        IntoIter {
-            front: Some(root1.first_leaf_edge()),
-            back: Some(root2.last_leaf_edge()),
-            length: len,
+        let mut me = ManuallyDrop::new(self);
+        if let Some(root) = me.root.as_mut() {
+            let root1 = unsafe { ptr::read(root).into_ref() };
+            let root2 = unsafe { ptr::read(root).into_ref() };
+            let len = me.length;
+
+            IntoIter {
+                front: Some(root1.first_leaf_edge()),
+                back: Some(root2.last_leaf_edge()),
+                length: len,
+            }
+        } else {
+            IntoIter { front: None, back: None, length: 0 }
         }
     }
 }