Scope in Rust
# Scope in Rust
scope begins where it’s created and ends at the end of the block, and through nested blocks.
|
|
x is available through the entire block
variables can be shadowed vars are always local to their scope
|
|
you can also shadow vars in the same scope
|
|
compiler will often discard earlier changes for optimization