Hacker News new | ask | show | jobs
by dathinab 543 days ago
some random additional information:

- initially it was believed you can rely Drop for soundness

- then the rust community realized that this is an oversight -- the so called leakocalipyse

- there also was no easy straight forward way to fix that, in the end it was decided that leaking must be sound and `std::mem::forget` was added

- while there was some initial fallout (e.g. scoped threads and some &mut iterators now leaking collections if leaked) it wasn't to bad as you still can use function scopes to enforce some non leaking (i.e. if you accept a closure you can make sure something runs both before and after it)

- but with async functions a lot of the workarounds don't work anymore as the async function could be leaked mid execution by calling async functions ... so by now some people which rust had taken a different turn back then. But then to be fair this is the kind of "hypothetically wishing" because making leak sound was with the knowledge and constraints available back then very clearly the right choice.

1 comments

One nitpick, `std::mem::forget` already existed it was just marked as unsafe before.