logoalt Hacker News

dangoodmanUTyesterday at 10:57 PM1 replyview on HN

waiting for someone to say "this wouldn't have happen if you chose rust"


Replies

woodruffwyesterday at 11:03 PM

You’ll probably be waiting a long time, since Rust very explicitly doesn’t have “leak safety” as a constructive property. Safe Rust programs are allowed to leak memory, because memory leaks themselves don’t cause safety issues.

There’s even a standard, non-unsafe API for leaking memory[1].

(What Rust does do is make it harder to construct programs that leak memory unintentionally. It’s possible but not guaranteed that a similar leak would be difficult to express idiomatically in Rust.)

[1]: https://doc.rust-lang.org/std/boxed/struct.Box.html#method.l...

show 1 reply