summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorfrogtd <31412003+frogtd@users.noreply.github.com>2021-09-25 04:52:18 -0400
committerGitHub <noreply@github.com>2021-09-25 10:52:18 +0200
commitd75759e829fdcd64ef071cf4b6eae2a011a7718b (patch)
treed614d7c9840d7984c4d7f2d31049d3eedc2f35d5 /exercises
parentdb9d7a907d876aec1db95bb959196c43eca7503d (diff)
fix(move_semantics5): change &mut *y to &mut x (#814)
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: <https://discord.com/channels/273534239310479360/273541522815713281/872689531428692040>
Diffstat (limited to 'exercises')
-rw-r--r--exercises/move_semantics/move_semantics5.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/exercises/move_semantics/move_semantics5.rs b/exercises/move_semantics/move_semantics5.rs
index 5449e95..1afe16c 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);