2 ms·
That's not how lifetimes work, and their strength is not in stopping memory leaks: both because they do not do that, and because memory leaks aren't the biggest
by dbaupp 8y ago
That's not how lifetimes work, and their strength is not in stopping memory leaks: both because they do not do that, and because memory leaks aren't the biggest problem.
Rust's lifetimes record when values are valid and when they're not that exist in the code statically (essentially the same ones that exist in C++ code), in a way that allows the compiler to check that they're being used correctly, that a valid (i.e. "can be used") value never points to or uses an invalid one.