Skip to content

Commit 2b6614f

Browse files
committed
treemap: use each_mut instead of mutate
1 parent 88278f9 commit 2b6614f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/libstd/treemap.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,14 +636,13 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
636636
fn heir_swap<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>,
637637
child: &mut Option<~TreeNode<K, V>>) {
638638
// *could* be done without recursion, but it won't borrow check
639-
do child.mutate |mut child| {
640-
if child.right.is_some() {
641-
heir_swap(node, &mut child.right);
639+
for child.each_mut |x| {
640+
if x.right.is_some() {
641+
heir_swap(node, &mut x.right);
642642
} else {
643-
node.key <-> child.key;
644-
node.value <-> child.value;
643+
node.key <-> x.key;
644+
node.value <-> x.value;
645645
}
646-
child
647646
}
648647
}
649648

@@ -689,7 +688,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
689688
save.level -= 1;
690689

691690
if right_level > save.level {
692-
do save.right.mutate |mut x| { x.level = save.level; x }
691+
for save.right.each_mut |x| { x.level = save.level }
693692
}
694693

695694
skew(save);

0 commit comments

Comments
 (0)