2 ms·
In this specific instance, with these types, sure. Imagine you had two different types, with a destructor defined, which did things. Any amount of code can run
by steveklabnik 12y ago
In this specific instance, with these types, sure. Imagine you had two different types, with a destructor defined, which did things. Any amount of code can run between those two things being free'd.
- borrowwhatnow 12y agoTrue, but pointers don't have destructors in C++ or Rust, I think (and in C, there are no destructors at all, obvs).
- steveklabnik 12y agoThese particular references don't, but many smart pointers do. The borrow checker doesn't currently do something different based on Drop. You can argue that it would be easier if it just made this work, but at the same time, there would be more special cases. Right now, the rule is very simple. We'll see once SEME regions and or non-lexical borrows land, though...