2 ms·
> but that part of the description doesn't catch how objects are automatically freed once the last reference to them (the owning one) is dropped. You're confus
by cesarb 1y ago
> but that part of the description doesn't catch how objects are automatically freed once the last reference to them (the owning one) is dropped.
You're confusing the borrow checker with RAII.
Dropping the last reference to an object does nothing (and even the exclusive &mut is not an "owning" reference). Dropping the object itself is what automatically frees it. See also Box::leak.
- gpm 1y agoNo I'm rather explicitly considering the joint behavior or the borrow checker and RAII. With only RAII you don't get the last reference part. Yes, there are exceptions, it's a roughly correct analogy not a precise description.