d75759e829
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>
16 lines
347 B
Rust
16 lines
347 B
Rust
// move_semantics5.rs
|
|
// Make me compile only be reordering the lines in `main()`, but without
|
|
// adding, changing or removing any of them.
|
|
// Execute `rustlings hint move_semantics5` for hints :)
|
|
|
|
// I AM NOT DONE
|
|
|
|
fn main() {
|
|
let mut x = 100;
|
|
let y = &mut x;
|
|
let z = &mut x;
|
|
*y += 100;
|
|
*z += 1000;
|
|
assert_eq!(x, 1200);
|
|
}
|