-
Notifications
You must be signed in to change notification settings - Fork 14.1k
UnsafePinned: update get() docs and signature to allow shared mutation #142162
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -86,11 +86,14 @@ impl<T: ?Sized> UnsafePinned<T> { | |||||
| ptr::from_mut(self) as *mut T | ||||||
| } | ||||||
|
|
||||||
| /// Get read-only access to the contents of a shared `UnsafePinned`. | ||||||
| /// Get mutable access to the contents of a shared `UnsafePinned`. | ||||||
| /// | ||||||
| /// Note that `&UnsafePinned<T>` is read-only if `&T` is read-only. This means that if there is | ||||||
| /// mutation of the `T`, future reads from the `*const T` returned here are UB! Use | ||||||
| /// [`UnsafeCell`] if you also need interior mutability. | ||||||
| /// This can be cast to a pointer of any kind. | ||||||
| /// Ensure that the access is unique (no active references, mutable or not) | ||||||
| /// when casting to `&mut T`, and ensure that there are no mutations | ||||||
| /// or mutable aliases going on when casting to `&T`. | ||||||
|
||||||
| /// | ||||||
| /// All the usual caveats around mutation shared state apply, see [`UnsafeCell`]. | ||||||
|
||||||
| /// All the usual caveats around mutation shared state apply, see [`UnsafeCell`]. | |
| /// All the usual caveats around mutation of shared state apply, see [`UnsafeCell`]. |
Uh oh!
There was an error while loading. Please reload this page.
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.
Since the second half of this, about casting to
&T, makes note about ensuring there are no ongoing foreign writes (i.e. even if no active references exist), perhaps the first half should as well, since I'd expect casting to&mut Tto have this same precondition.