News for hackers. Stuff that matters.
Re:A half-hour to learn Rust by kd5bjo on Saturday January 02, 2021 @02:51AM (#25611159)
No, it really is shadowing. The second `let` allocates a new memory location in the activation record; all future mentions of the variable name will refer to the new location. The old location still exists, and may have references to it already; references that will continue pointing at the old allocation and will not see anything that happens to the new one. If the old value has a `Drop` implementation, it will run after the second allocation’s `drop()`. The two `let` bindings can even have completely different types.

There are no comments on this comment yet.