Skip to content

Commit d75759e

Browse files
authored
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>
1 parent db9d7a9 commit d75759e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

exercises/move_semantics/move_semantics5.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
fn main() {
99
let mut x = 100;
1010
let y = &mut x;
11-
let z = &mut *y;
11+
let z = &mut x;
1212
*y += 100;
1313
*z += 1000;
1414
assert_eq!(x, 1200);

0 commit comments

Comments
 (0)