4 ms·
RefCell is distinct from Cell, more common, but much worse tradeoffs for implicit access, because accessing it can crash your program.
by gpm 5y ago
RefCell is distinct from Cell, more common, but much worse tradeoffs for implicit access, because accessing it can crash your program.
- nyanpasu64 5y agoI want Cell to be more ergonomic because it addresses the same Rust weak points as RefCell but without runtime overhead and panicking. I think RefCell<struct> should be an infrequently used type that you reach for when you specifically want to guard against reentrancy, and struct{Cell} should be the primary replacement for shared access in other languages. The latter is sound but introduces a lot of boilerplate syntax.