-
Notifications
You must be signed in to change notification settings - Fork 13.4k
std: expand the Share
docs to make them more precise.
#13070
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
Conversation
/// For cases when one does need thread-safe interior mutability, | ||
/// types like the atomics in `std::sync` and `Mutex` & `RWArc` in the | ||
/// `sync` crate do ensure that any mutation cannot cause data races. | ||
/// Hence these types are `Share`. |
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.
This may want to change the mention of RWArc
to Arc
and/or RWLock
in preparation for my sync rewrite.
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.
Oh, whoops, I was actually meaning to write those new forms, but habit hijacked my keyboard.
(Updated.)
cc @nikomatsakis, just want to make sure you agree with this. Otherwise, this looks good to me. |
/// A somewhat surprising consequence of the definition is `&mut T` is | ||
/// `Share` (if `T` is `Share`) even though it seems that it might | ||
/// provide unsynchronised mutation. When in an aliasable spot as `& | ||
/// &mut T`, a mutable reference becomes read-only, as if it were a `& |
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.
nit: could you put the & &mut T
and & &T
in the same line? Just to make it more readable.
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.
I reworded this section to get the line breaks to line up nicer; just for you, @flaper87 ;P
(BTW, it did render correctly in the HTML even with the linebreaks.)
very nice, thanks for expanding the |
These look good. My only caveat is that perhaps we should mention that if you are writing your own type with interior mutability, you must use |
And give some examples about exactly what's `Share` and what's not.
Updated the last paragraph to include |
std: expand the `Share` docs to make them more precise. And give some examples about exactly what's `Share` and what's not.
std: expand the `Share` docs to make them more precise. And give some examples about exactly what's `Share` and what's not.
std: expand the
Share
docs to make them more precise.And give some examples about exactly what's
Share
and what's not.