Hacker News new | ask | show | jobs
by mcguire 2214 days ago
Apparently, that doesn't work in Rust: https://news.ycombinator.com/item?id=23363647
2 comments

It does work in rust. you just cannot rely on Drop for memory-safety. If you mem::forget a struct that holds onto some other resource then all that means is that you're committing that resource to the lifetime of the process. We usually call that a leak but it can be intentional.
By that argument, it doesn't work in C++ either because std::unique_ptr::release() exists.