-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend interior mutability (e.g. Cell) for better composition with other types. #1106
Comments
Hm, would it work to make
|
So I assume you are talking abput However, to fully implement an API for Implementing a "never calls |
@eddyb So I came back here from the other thread and I think still don't really understand the |
@glaebhoerl sorry, I have no idea how I missed your comment here. That means the |
It's not just |
@glaebhoerl |
I like the idea of
Can we clarify whether that transmute is UB? Note that similar transmutes of questionable validity already appear in a few places in libstd (e.g. It would be nice to officially have a rule that it's valid to transmute from This rule would imply it's OK to transmute |
A couple of ideas were outlined in this reddit comment.
1: Implementing the API for
Cell<Rc<T>>
andCell<Vec<T>>
: requires a lot ofunsafe
.There might be a way to provide mutable access to the contents of
Cell
viaCell::with_mut(|mut_ref| {...})
and have the compiler prove that the closure cannot reach theCell::with_mut
entry point, but it's not something we can express right now.2: Turning
&mut T
into multiple aliases withCell
semantics:I am not certain this is UB-free, but if it isn't, I still expect @glaebhoerl's
CellRef<'a, T>
suggestion to work.cc @nikomatsakis
The text was updated successfully, but these errors were encountered: