4 ms·
Isn't Rc<T> essentially garbage collection though?
by pasabagi 6y ago
Isn't Rc<T> essentially garbage collection though?
- amelius 6y agoReference counting is a form of garbage collection, but with closures you often end up with circular dependencies, which is what RC can't handle.
- ivanbakel 6y agoNot really. Reference counting doesn't prevent reference loops, and reference loops which aren't reachable from code are memory leaks - which is why garbage collectors do sweeps to detect unreachable memory. Rust doesn't have any kind of automatic cleanup of unreachable memory if you bypass the borrow-checker. Rust is a language for memory management. There is no way to write code in Rust without thinking about memory.