Skip to content

Commit

Permalink
Rearrange BTreeMap::into_iter to match range_mut.
Browse files Browse the repository at this point in the history
  • Loading branch information
ssomers committed Apr 10, 2020
1 parent 0c835b0 commit 4ade06b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
}
Expand Down

0 comments on commit 4ade06b

Please sign in to comment.