treemap: use each_mut instead of mutate

This commit is contained in:
Daniel Micay 2013-03-15 14:14:03 -04:00
parent 88278f9c35
commit 2b6614f2e6

View File

@ -636,14 +636,13 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
fn heir_swap<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>, fn heir_swap<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>,
child: &mut Option<~TreeNode<K, V>>) { child: &mut Option<~TreeNode<K, V>>) {
// *could* be done without recursion, but it won't borrow check // *could* be done without recursion, but it won't borrow check
do child.mutate |mut child| { for child.each_mut |x| {
if child.right.is_some() { if x.right.is_some() {
heir_swap(node, &mut child.right); heir_swap(node, &mut x.right);
} else { } else {
node.key <-> child.key; node.key <-> x.key;
node.value <-> child.value; node.value <-> x.value;
} }
child
} }
} }
@ -689,7 +688,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
save.level -= 1; save.level -= 1;
if right_level > save.level { if right_level > save.level {
do save.right.mutate |mut x| { x.level = save.level; x } for save.right.each_mut |x| { x.level = save.level }
} }
skew(save); skew(save);