Think about the scope

What is actually happening with this code is that we created a new scope for the borrowing section of the code, which passes back in to mutvar before the final println! is reached. In other words, the scope changes; therefore, when mutvar is hit on the println!, no borrowing is occurring and we're just displaying whatever is bound to the mutvar variable.

If we want to remove the braces, we will have to ensure that the borrowing has finished before we output through println!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset