mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-27 00:00:03 +03:00
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>
This commit is contained in:
parent
db9d7a907d
commit
d75759e829
|
@ -8,7 +8,7 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut x = 100;
|
let mut x = 100;
|
||||||
let y = &mut x;
|
let y = &mut x;
|
||||||
let z = &mut *y;
|
let z = &mut x;
|
||||||
*y += 100;
|
*y += 100;
|
||||||
*z += 1000;
|
*z += 1000;
|
||||||
assert_eq!(x, 1200);
|
assert_eq!(x, 1200);
|
||||||
|
|
Loading…
Reference in a new issue