think what I've learned this morning is that RefCell is for mutating inside short-lived borrows, whereas I'm attempting to extract long-lived references from something, intertwined with mutating it, which is never going to work
-
Show this thread
-
Replying to @mountain_ghosts
I've always thought that refcell was more for temporarily extracting mutable references from behind shared references and applying runtime borrow rules to those temporary inner borrows which sounds like what you're trying to do...
1 reply 0 retweets 0 likes -
Replying to @yaahc_ @mountain_ghosts
Actually I guess that's exactly cells responsibility. I really don't understand refcell I think...
1 reply 0 retweets 0 likes -
Replying to @yaahc_ @mountain_ghosts
Cell is T and RefCell is &T
1 reply 0 retweets 1 like -
Cell lets you mutate a non-mutable T, and RefCell lets you mutate a non-mutable &T
2 replies 0 retweets 2 likes -
Replying to @steveklabnik @mountain_ghosts
They both own the data though right? And they both allow getting &mut T from an &.*Cell<T> right?
2 replies 0 retweets 1 like -
Cell does not have anything that is `fn(&self) -> &mut T`. It does have a `fn(&mut self) -> &mut T`, but that's not useful for interior mutability.
1 reply 0 retweets 2 likes -
Well shit now I'm even more confusered. I will dig into this later. I need to focus on moving right now x.x
3 replies 0 retweets 4 likes -
You're probably thinking of UnsafeCell which is pub const fn(&self) -> *mut T
2 replies 0 retweets 2 likes
FWIW every type in `std::cell` has that signature
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.