When we want to extract the value inside the
Arc, we usually use:
pub fn get_mut(this: &mut Self) -> Option<&mut T>;
It's very rare to me that using a
&mut Arc<T>, I wondered why this function must take a
&mut Self? What's the danger if it takes a
If it took
&self then you would still be able to dereference the
deref and get another another reference to the same
T, thus breaking the borrowing rules.
It would also be possible to clone the
Arc and get simultaneous access that way.
Sorry for asking a silly question, I'v been coding for hours without sleeping, and now I'm experiencing some serious brain fog
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.