Skip to content

Commit ca8f09a

Browse files
committed
use mut function argument syntax in priority_queue
1 parent aff3db2 commit ca8f09a

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/libstd/priority_queue.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ impl <T: Ord> PriorityQueue<T> {
7676
}
7777

7878
/// Optimized version of a push followed by a pop
79-
fn push_pop(&mut self, item: T) -> T {
80-
let mut item = item;
79+
fn push_pop(&mut self, mut item: T) -> T {
8180
if !self.is_empty() && self.data[0] > item {
8281
item <-> self.data[0];
8382
self.siftdown(0);
@@ -86,8 +85,7 @@ impl <T: Ord> PriorityQueue<T> {
8685
}
8786

8887
/// Optimized version of a pop followed by a push - fails if empty
89-
fn replace(&mut self, item: T) -> T {
90-
let mut item = item;
88+
fn replace(&mut self, mut item: T) -> T {
9189
item <-> self.data[0];
9290
self.siftdown(0);
9391
item
@@ -129,9 +127,8 @@ impl <T: Ord> PriorityQueue<T> {
129127
// vector over the junk element. This reduces the constant factor
130128
// compared to using swaps, which involves twice as many moves.
131129

132-
priv fn siftup(&mut self, start: uint, pos: uint) {
130+
priv fn siftup(&mut self, start: uint, mut pos: uint) {
133131
unsafe {
134-
let mut pos = pos;
135132
let new = move *addr_of(&self.data[pos]);
136133

137134
while pos > start {
@@ -149,9 +146,8 @@ impl <T: Ord> PriorityQueue<T> {
149146
}
150147
}
151148

152-
priv fn siftdown_range(&mut self, pos: uint, end: uint) {
149+
priv fn siftdown_range(&mut self, mut pos: uint, end: uint) {
153150
unsafe {
154-
let mut pos = pos;
155151
let start = pos;
156152
let new = move *addr_of(&self.data[pos]);
157153

0 commit comments

Comments
 (0)