3 ms·
Rust solves this dilemma with lifetimes. As long as a reference exists to data, Rust statically ensures that you cannot perform any operation that frees or mov
by Jweb_Guru 12y ago
Rust solves this dilemma with lifetimes. As long as a reference exists to data, Rust statically ensures that you cannot perform any operation that frees or moves it in memory. In the case of multiple threads, one can also assign each thread a lifetime, and perform the same analysis to maintain existence guarantees. Things get a bit trickier if you want to actually mutate the shared reference, but in the case of truly immutable data that's really all you need.