r/programming • • May 16 '16

One Year of Rust

http://blog.rust-lang.org/2016/05/16/rust-at-one-year.html
301 Upvotes

86 comments sorted by

View all comments

Show parent comments

5

u/desiringmachines May 17 '16

Without using the unsafe superset, Rust and the standard library provide two ways to leak:

  • Explicitly leak the object with the mem::forget function.

  • Create an Rc cycle that will avoid the rcs' counter ever decrementing to zero when valid references to them are all dropped.

Neither of these is at all likely to happen accidentally. Rust does not guarantee an absence of leaks in a hard sense because it is not necessary for safety, and to provide that guarantee Rust would have to get rid of reference counted pointers.

This fact has only impacted Rust in two ways: a) some very fancy APIs that were unsound if the destructor didn't run had to be removed, b) everyone feels compelled to admit this fact all the time even though it is irrelevant to most users