4 ms·
Of course, Cell has its own overhead, which is why using large Cells is often worse than just using Rc. It's also very situational; we often have types which do
by verdagon 4y ago
Of course, Cell has its own overhead, which is why using large Cells is often worse than just using Rc. It's also very situational; we often have types which don't work with Cell, and it often doesn't make sense to copy objects in many use cases.
It's one of those things that works well in theory, but in practice can fall short.
- Rusky 4y agoThat's totally beside the point here: you can do a mechanical (thus "trivial") translation from JavaScript-like code to Rc+Cell, without ever hitting that overhead. That is, JavaScript-like code simply doesn't do large assignments in the first place. It doesn't directly hold move-only objects that are trickier to use with Cell. If you find yourself hitting those cases, you have left the realm of JavaScript-like code, and entered the realm of manual memory management.
- verdagon 4y ago> The limitations of &mut cannot be trivially worked around. > The "trivial" equivalent to JavaScript is not RefCell, but plain old Cell, applied at the level of individual fields you want to write to. No panics and no (relative) overhead there. I thought you were implying that we could trivially work around Rust's problems by just using Cell everywhere, my comment was in response to that. It seems now that you were talking about something else, so nevermind =)