3 ms·
Doing std::mem::forget is not unsafe as you cannot get any sort of undefined behavior which is what Rust protects you from [0]. Leaking is pretty safe, not alw
by etra0 4y ago
Doing std::mem::forget is not unsafe as you cannot get any sort of undefined behavior which is what Rust protects you from [0].
Leaking is pretty safe, not always desired but definitely not dangerous like random pointers derefs.
But as OP says, leaking accidentally is uncommon.
[0] https://doc.rust-lang.org/nomicon/safe-unsafe-meaning.html https://doc.rust-lang.org/nomicon/safe-unsafe-meaning.html