-
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
Pre-RFC: generalize std::cell::Cell to non-Copy types #1164
Comments
cc #1106 |
I always felt Cell was too limiting and you finally figured out what was missing! IMO |
@cristicbz Yeah, I’m not super happy with the name of |
Thinking a bit more, I’d like to have 1. and 2. in |
FWIW a more general way to formulate it would be something like (see also @eddyb's link):
(various details and annotations omitted) This would subsume the existing Another thing you could do: while it's not safe to have references to the interiors of |
|
@glaebhoerl Any reason |
@eddyb I don't know. It seems weird to me. But maybe it's not. Don't have any deeper thoughts. :)
Hm? |
@glaebhoerl I don’t understand what |
@glaebhoerl the Actually, splitting a If there is another problematic case, related or not to the hypothetical |
@SimonSapin It's a shared shallow-mutable reference type - you can copy it and |
Doing 1 and 2 is attractive, but having some operations only work in some cases (#1164 (comment)) makes it weird. |
I’ve been experimenting with a
MoveCell
type that’s a lot likestd::cell::Cell
, except it also works with types that are notCopy
. When discussing it, the idea came up that at least some of its functionality could be added toCell
itself:The
T: Copy
bound is not required at all forCell::new
andCell::set
and could be removed.A
replace
method could be added (also withoutT: Copy
):More of
MoveCell
’s methods (such aspeek
whereT: Default
) could be added.Does this sound like something we want to do with
Cell
, or is this functionality better off in a separate type? (Note that this separate type can and has been done outside ofstd
on stable Rust.)CC @alexcrichton @aturon
The text was updated successfully, but these errors were encountered: