Okay.
The documentation page for std::mem::forget goes through all the alternatives you should try before resorting to std::mem::forget.
Now, perhaps std::mem::forget should be marked unsafe. However, you don't just "accidentally" run std::mem::forget.
BTW, one of the problems with GC languages is the fact that you never know when your destructor might get run (ie. object gets reclaimed) so your GC thinks life is just fine but ... oops ... you just ran out of file descriptors because they are all waiting to be reclaimed.
It was in the past IIRC. The problem is that there are multiple ways to leak resources in safe Rust (e.g. creating `Rc` cycles), and the compiler cannot prevent them all. So leaking is safe, and because it's also useful sometimes, `std::mem::forget()` and friends (e.g. `Box::leak()`) are also safe. That being said, it is pretty hard to accidentally leak memory.
That's how they solve it, C# is my fav language, but it's probably because I've only really spent time in C++ and C#, the rest is just "scripting". So the syntax is familiar.
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
Leaking in Rust requires either explicit leaking function call, leaking in C/FFI code, or a type that is 1. recursive 2. refcounted 3. with interior mutability, and 4. a programming error in use of such type. If any of these four conditions aren’t met, it can’t leak.