playing with the mutable references
This commit is contained in:
parent
62b4865c9c
commit
0a2003dfc8
21 changed files with 6 additions and 1 deletions
|
@ -9,8 +9,13 @@ fn main() {
|
||||||
println!("t 2nd: {}", t.1);
|
println!("t 2nd: {}", t.1);
|
||||||
|
|
||||||
let mut x: i32 = 10;
|
let mut x: i32 = 10;
|
||||||
|
let mut z: i32 = 5;
|
||||||
println!("x: {x}");
|
println!("x: {x}");
|
||||||
let ref_x: &mut i32 = &mut x;
|
println!("z: {z}");
|
||||||
|
let mut ref_x: &mut i32 = &mut x;
|
||||||
*ref_x = 20;
|
*ref_x = 20;
|
||||||
println!("x: {x}");
|
println!("x: {x}");
|
||||||
|
ref_x = &mut z;
|
||||||
|
*ref_x = 20;
|
||||||
|
println!("z: {z}");
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue