Skip to content

Commit b1f04c0

Browse files
petertsengijanos
authored andcommitted
grade-school, bowling: Remove unnecessary mut (#346)
`iter_mut()` and `or_insert()` yields mutable references, the variables they bind to does not need to be mutable. Previously, because of rust-lang/rust#30280 this was not considered a warning. The fix is in rust-lang/rust#43582 This means on recently nightlies this warning is emitted.
1 parent 8df7191 commit b1f04c0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

exercises/bowling/example.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl BowlingGame {
104104
return Err("Game Finished. No more rolls.");
105105
}
106106

107-
for mut frame in self.frames.iter_mut() {
107+
for frame in self.frames.iter_mut() {
108108
frame.add_roll(pins)
109109
}
110110

exercises/grade-school/example.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ impl School {
1010
}
1111

1212
pub fn add(&mut self, grade: u32, student: &str) {
13-
let mut entry = self.grades.entry(grade).or_insert(Vec::new());
13+
let entry = self.grades.entry(grade).or_insert(Vec::new());
1414
entry.push(student.to_string());
1515
entry.sort();
1616
}

0 commit comments

Comments
 (0)