Concern stemming from video
NYLUG Presents - Steve Klabnik on Why Rust
time 48:06
fn main() {
let mut x = 5;
x = 6;
}
In the above, the binding 'x' - that is, the memory location known as x - can be changed. However, the '5' cannot, so that writing "x = 6;" means that the location that x is referring to has changed. Did the memory location that held the 5 get freed when x was assigned the location where the compiler put the 6?
Here is my concern. Considering the above explanation, it would seem that if I changed the line "x = 6" to "x = i" and put "x = i" in a loop, 1 to a trillion, then the compiler would have to assign a trillion memory locations, which is not the right thing.
Is this a real concern? If not, why not? How is this to be thought of?
Thanks