-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Update cell.rs, correct module level doc #146863
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
base: master
Are you sure you want to change the base?
Conversation
This change corrects the Cell<T> section by replacing `&mut` with `&` so the statement reads "an &T to the inner value can never be obtained". It also emphasizes that a single &mut T to the inner value can be obtained (e.g. via method core::cell::Cell::get_mut).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few small things, please squash after as well
//! | ||
//! [`Cell<T>`] implements interior mutability by moving values in and out of the cell. That is, an | ||
//! `&mut T` to the inner value can never be obtained, and the value itself cannot be directly | ||
//! `& T` to the inner value can never be obtained, and the value itself cannot be directly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe more clear as "&T
or &mut T
".
Also, this should be &T
rather than & T
(no space).
//! `& T` to the inner value can never be obtained, and the value itself cannot be directly | ||
//! obtained without replacing it with something else. Both of these rules ensure that there is | ||
//! never more than one reference pointing to the inner value. This type provides the following | ||
//! never more than one mutable reference pointing to the inner value. This type provides the following |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original was correct here; we also can't have >1 shared reference (because .set(x)
would replace the value they point to).
This change corrects the Cell section by replacing
&mut
with&
so the statement reads "an &T to the inner value can never be obtained". It also emphasizes that a single &mut T to the inner value can be obtained (e.g. via method core::cell::Cell::get_mut).