I'm learning Rust and was referencing a book in which the author says that the following piece of code would give compile error:
fn main() {
let mut x = 10;
println!("x old val is {}", x);
// {
let y = &mut x;
*y += 1;
// }
println!("x new val is {}", x);
}
But to my surprise I'm not getting any error when I run it. Can somebody explain this example in detail. I'm using Rust version 1.41.0