-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
expand the documentation on the Unpin
trait
#53104
Changes from 5 commits
038ce65
6845dc4
9b7d710
87bbd2e
68e766a
03530fa
6ae915b
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 |
---|---|---|
|
@@ -603,15 +603,22 @@ unsafe impl<T: ?Sized> Freeze for *mut T {} | |
unsafe impl<'a, T: ?Sized> Freeze for &'a T {} | ||
unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {} | ||
|
||
/// Types which can be moved out of a `PinMut`. | ||
/// Types which can be safely moved after being pinned. | ||
/// | ||
/// The `Unpin` trait is used to control the behavior of the [`PinMut`] type. If a | ||
/// type implements `Unpin`, it is safe to move a value of that type out of the | ||
/// `PinMut` pointer. | ||
/// Since Rust itself has no notion of immovable types, and will consider moves to always be safe, | ||
/// this trait cannot prevent types from moving by itself. | ||
/// | ||
/// Instead it can be used to prevent moves through the type system, | ||
/// by controlling the behavior of special pointers types like [`PinMut`], | ||
/// which "pin" the type in place by wrapping it in a type which can only be dereferenced immutably. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the "by ..." part help? It doesn't really explain anything, does it? Maybe just link to the PinMut docs. Or maybe say something along the lines of "by not allowing it to be moved out e.g. through mutable references (unless |
||
/// | ||
/// Implementing this trait lifts the restrictions of pinning off a type, | ||
/// which then allows it to move out of said pointers with functions such as [`swap`]. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The remark to |
||
/// | ||
/// This trait is automatically implemented for almost every type. | ||
/// | ||
/// [`PinMut`]: ../mem/struct.PinMut.html | ||
/// [`swap`]: ../mem/fn.swap.html | ||
#[unstable(feature = "pin", issue = "49150")] | ||
pub auto trait Unpin {} | ||
|
||
|
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.
"pointer types" (spurious "s")