News for hackers. Stuff that matters.
Re:My favorite Rust function by Filligree on Saturday October 12, 2019 @07:52PM (#21237185)
It used to be at the end of the block, which caused all manner of annoyance. So they spent a lot of effort improving the borrow checker, and now it's 'after last use'.

It's not just a matter of memory use. References and mutable references form a sort of compile-time read-write mutex; you can't take a mutable reference without first dropping all other references. See https://stackoverflow.com/questions/50251487/what-are-non-le... for more.

Re:My favorite Rust function by edflsafoiewq on Saturday October 12, 2019 @08:10PM (#21237277)
NLL didn't affect when objects get dropped. That would be a breaking change. Things still get dropped at end of block (well, approximately... the exact rule is actual quite complex).
Re:My favorite Rust function by Rusky on Saturday October 12, 2019 @08:09PM (#21237275)
This is incorrect. Values still go out of scope and have their destructors run at the same time.

NLL only affects values without destructors.

Re:My favorite Rust function by oconnor663 on Saturday October 12, 2019 @08:22PM (#21237327)
I think `#[may_dangle]` is an exception to this, and the standard library puts it on many (most?) container types.
Re:My favorite Rust function by Rusky on Saturday October 12, 2019 @08:34PM (#21237374)
It is not an exception; #[may_dangle] does not change the time drop runs. All it does is promise that drop will not access borrowed data, allowing that data to die before drop: https://doc.rust-lang.org/nightly/nomicon/dropck.html