From 40b7c1deae35fff8f928f6b0a50186ffd44745a9 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Thu, 24 Aug 2017 01:12:19 -0700 Subject: [PATCH 1/2] bowling: Remove unnecessary `mut` The `iter_mut` yields mutable references; `frame` does not need to be mutable. Previously, because of https://github.com/rust-lang/rust/issues/30280 this was not considered a warning. The fix is in https://github.com/rust-lang/rust/pull/43582 This means on recently nightlies this warning is emitted. --- exercises/bowling/example.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/bowling/example.rs b/exercises/bowling/example.rs index 089ef3dcb..547c4b9ce 100644 --- a/exercises/bowling/example.rs +++ b/exercises/bowling/example.rs @@ -104,7 +104,7 @@ impl BowlingGame { return Err("Game Finished. No more rolls."); } - for mut frame in self.frames.iter_mut() { + for frame in self.frames.iter_mut() { frame.add_roll(pins) } From 2c40df697837af6924cb907609e9984e0746977b Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Thu, 24 Aug 2017 01:12:23 -0700 Subject: [PATCH 2/2] grade-school: Remove unnecessary `mut` The `or_insert` already returns a mutable reference; `entry` does not need to be mutable. Previously, because of https://github.com/rust-lang/rust/issues/30280 this was not considered a warning. The fix is in https://github.com/rust-lang/rust/pull/43582 This means on recently nightlies this warning is emitted. --- exercises/grade-school/example.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/grade-school/example.rs b/exercises/grade-school/example.rs index 58f9e1e51..3b2cc7910 100644 --- a/exercises/grade-school/example.rs +++ b/exercises/grade-school/example.rs @@ -10,7 +10,7 @@ impl School { } pub fn add(&mut self, grade: u32, student: &str) { - let mut entry = self.grades.entry(grade).or_insert(Vec::new()); + let entry = self.grades.entry(grade).or_insert(Vec::new()); entry.push(student.to_string()); entry.sort(); }