Shadowing in Rust
I started learning Rust recently and so far I am impressed. The docs have been easy to follow, the design choices clearly explained. I don’t remember another language learning experience being this pleasant. Three chapters in, what stands out to me is the concept of shadowing – declaring a variable with the same name as an existing variable. When you shadow, you temporarily transform a variable that will return to an immutable state after the scope ends. That way, you can change the data type of a variable while reusing its name. As I am discovering, Rust is full of neat, thoughtful features like this: