diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 01b62797a8d..5231d51e31e 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -76,8 +76,7 @@ impl PriorityQueue { } /// Optimized version of a push followed by a pop - fn push_pop(&mut self, item: T) -> T { - let mut item = item; + fn push_pop(&mut self, mut item: T) -> T { if !self.is_empty() && self.data[0] > item { item <-> self.data[0]; self.siftdown(0); @@ -86,8 +85,7 @@ impl PriorityQueue { } /// Optimized version of a pop followed by a push - fails if empty - fn replace(&mut self, item: T) -> T { - let mut item = item; + fn replace(&mut self, mut item: T) -> T { item <-> self.data[0]; self.siftdown(0); item @@ -129,9 +127,8 @@ impl PriorityQueue { // vector over the junk element. This reduces the constant factor // compared to using swaps, which involves twice as many moves. - priv fn siftup(&mut self, start: uint, pos: uint) { + priv fn siftup(&mut self, start: uint, mut pos: uint) { unsafe { - let mut pos = pos; let new = move *addr_of(&self.data[pos]); while pos > start { @@ -149,9 +146,8 @@ impl PriorityQueue { } } - priv fn siftdown_range(&mut self, pos: uint, end: uint) { + priv fn siftdown_range(&mut self, mut pos: uint, end: uint) { unsafe { - let mut pos = pos; let start = pos; let new = move *addr_of(&self.data[pos]); diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 68fff9ecb39..1f285b992c7 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -572,9 +572,8 @@ pure fn each_reverse(node: &Option<~TreeNode>, } // Remove left horizontal link by rotating right -fn skew(node: ~TreeNode) -> ~TreeNode { +fn skew(mut node: ~TreeNode) -> ~TreeNode { if node.left.map_default(false, |x| x.level == node.level) { - let mut node = node; let mut save = node.left.swap_unwrap(); node.left <-> save.right; // save.right now None save.right = Some(node); @@ -586,10 +585,9 @@ fn skew(node: ~TreeNode) -> ~TreeNode { // Remove dual horizontal link by rotating left and increasing level of // the parent -fn split(node: ~TreeNode) -> ~TreeNode { +fn split(mut node: ~TreeNode) -> ~TreeNode { if node.right.map_default(false, |x| x.right.map_default(false, |y| y.level == node.level)) { - let mut node = node; let mut save = node.right.swap_unwrap(); node.right <-> save.left; // save.left now None save.left = Some(node); @@ -628,8 +626,7 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { fn heir_swap(node: &mut TreeNode, child: &mut Option<~TreeNode>) { // *could* be done without recursion, but it won't borrow check - do child.mutate |child| { - let mut child = child; + do child.mutate |mut child| { if child.right.is_some() { heir_swap(&mut *node, &mut child.right); } else { @@ -682,15 +679,13 @@ fn remove(node: &mut Option<~TreeNode>, key: &K) -> bool { save.level -= 1; if right_level > save.level { - do save.right.mutate |x| { - let mut x = x; x.level = save.level; x - } + do save.right.mutate |mut x| { x.level = save.level; x } } save = skew(save); - do save.right.mutate |right| { - let mut right = skew(right); + do save.right.mutate |mut right| { + right = skew(right); right.right.mutate(skew); right }