4 ms·
Just FYI, `Arc<RefCell<T>>` wouldn't actually be useful, because you could not send it to other threads (`RefCell<T>` is not `Sync`). By your definition the "m
by Jweb_Guru 11y ago
Just FYI, `Arc<RefCell<T>>` wouldn't actually be useful, because you could not send it to other threads (`RefCell<T>` is not `Sync`). By your definition the "most permissive" thing would be `Arc<Mutex<T>>` and that hopefully makes it clearer why this would be a terrible default (`RefCell` has similar tradeoffs to those of a `Mutex` that killed your program when it detected deadlock, and `Arc` can leak memory). Rust absolutely gets the tradeoffs right here.
BTW, if you want a language where refcounting is the predominant approach (and where the compiler is built around it), but is otherwise very similar to Rust, you almost certainly want Swift.