From ffab0c4000273d37842ac8ccd9d74a87aea9e818 Mon Sep 17 00:00:00 2001 From: frogtd <31412003+frogtd@users.noreply.github.com> Date: Thu, 5 Aug 2021 00:48:11 -0400 Subject: [PATCH] Change &mut *y to &mut x Instead of having to explain why ```rs let mut x = 100; let y = &mut x; let mut z_owned = *y; let z = &mut z_owned; *y += 100; *z += 1000; ``` and ```rs let mut x = 100; let y = &mut x; let z = &mut *y; *y += 100; *z += 1000; ``` are different, you still get the point across about having only one mutable reference. As it stands, this exercise does too much (dereferencing and having only one mutable reference), and by doing so confuses people. Example of someone being confused by this: --- exercises/move_semantics/move_semantics5.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/move_semantics/move_semantics5.rs b/exercises/move_semantics/move_semantics5.rs index 5449e951..1afe16c5 100644 --- a/exercises/move_semantics/move_semantics5.rs +++ b/exercises/move_semantics/move_semantics5.rs @@ -8,7 +8,7 @@ fn main() { let mut x = 100; let y = &mut x; - let z = &mut *y; + let z = &mut x; *y += 100; *z += 1000; assert_eq!(x, 1200);