Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upExtend interior mutability (e.g. Cell) for better composition with other types. #1106
Comments
This comment has been minimized.
This comment has been minimized.
|
Hm, would it work to make
|
This comment has been minimized.
This comment has been minimized.
|
So I assume you are talking abput However, to fully implement an API for Implementing a "never calls |
eddyb
referenced this issue
Jun 18, 2015
Closed
Pre-RFC: generalize std::cell::Cell to non-Copy types #1164
This comment has been minimized.
This comment has been minimized.
|
@eddyb So I came back here from the other thread and I think still don't really understand the |
This comment has been minimized.
This comment has been minimized.
|
@glaebhoerl sorry, I have no idea how I missed your comment here. That means the |
This comment has been minimized.
This comment has been minimized.
|
It's not just |
This comment has been minimized.
This comment has been minimized.
|
@glaebhoerl |
This comment has been minimized.
This comment has been minimized.
|
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 |
eddyb commentedMay 6, 2015
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
CellviaCell::with_mut(|mut_ref| {...})and have the compiler prove that the closure cannot reach theCell::with_mutentry point, but it's not something we can express right now.2: Turning
&mut Tinto multiple aliases withCellsemantics: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