Hacker News new | ask | show | jobs
by gpm 1605 days ago
Needing to use a `Cell` in rust is incredibly rare in my experience. It's very far from clear to me that the increased complexity coming from allowing overriding the meaning of `=`, and worse of `variable_name_that_happens_to_contain_a_certain_type` would be remotely worth it.
1 comments

Unless GUI code comes up with Rc<RefCell<>> all over the place.
RefCell is distinct from Cell, more common, but much worse tradeoffs for implicit access, because accessing it can crash your program.
I 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.