Scopes and lifetimes

Variables like x have liveness and drop scopes, but they don't have lifetimes

I find this statement a little confusing, as both the original book talks about the lifetimes of variables (the first example here is the same one we're talking about and it starts with "we've annotated the lifetime of r"), and so does Rust by example ("Specifically, a variable's lifetime begins when it is created and ends when it is destroyed.")? A variable (or, actually, the value the variable owns) is created and at some point is destroyed - that period of time is not the lifetime of that variable?

1 Like