3 ms·
Ownership serves another important purpose: it determines when a value is freed.
by arnsholt 1y ago
Ownership serves another important purpose: it determines when a value is freed.
- zelphirkalt 1y agoI guess it is then a necessary complication of the language, as it doesn't have garbage collection, and as such doesn't notice, when values go out of scope of all closures that reference them?
- steveklabnik 1y agoYes, but it’s more subtle than that. What Rust does is track when the object goes out of scope, and will make sure that any closures that reference it live for a shorter time than that. Sort of backwards of what you’re asking.
- pclmulqdq 1y agoThe borrow checker is a compile-time garbage collector. If you think about it in that sense, you can understand a lot of the ways it restricts you.