Hacker News new | ask | show | jobs
by etra0 1694 days 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