Rust is my first language after Python, so I'm try to understand all the reference/pointer stuff by playing with and reading about it.
I don't understand difference between the cases below.
Simple - no problems here
let mut val_a = 5;
println!("val_a is {}", val_a);
val_a = 10;
println!("Now val_a is {}", val_a);
Not simple - borrowing issues
let mut val_b = 5;
let val_b_ref = &mut val_b;
println!("val_b by ref is {}", val_b_ref);
// Can not call line below because of further mutation of val_b
// println!("val_b is {}", val_b);
*val_b_ref = 20;
println!("val_b by ref is {}", val_b_ref);
// Now val_b can be called since no mutation after that
println!("val_b is {}", val_b);
I do not understand why in first case I can print val_a despite it being mutated after, while I cannot print val_b when it's mutated via deref operator.