1616//! [`Pin`] wraps a pointer type, so `Pin<Box<T>>` functions much like a regular `Box<T>`
1717//! (when a `Pin<Box<T>>` gets dropped, so do its contents, and the memory gets deallocated).
1818//! Similarily, `Pin<&mut T>` is a lot like `&mut T`. However, [`Pin`] does not let clients actually
19- //! obtain a `Box` or reference to pinned data, which implies that you cannot use
19+ //! obtain a `Box<T> ` or `&mut T` to pinned data, which implies that you cannot use
2020//! operations such as [`mem::swap`]:
2121//! ```
2222//! use std::pin::Pin;
2929//! ```
3030//!
3131//! It is worth reiterating that [`Pin`] does *not* change the fact that a Rust compiler
32- //! considers all types movable. [`mem::swap`] remains callable for any `T`. Instead, `Pin`
32+ //! considers all types movable. [`mem::swap`] remains callable for any `T`. Instead, `Pin`
3333//! prevents certain *values* (pointed to by pointers wrapped in `Pin`) from being
34- //! moved by making it impossible to call methods like [`mem::swap`] on them.
34+ //! moved by making it impossible to call methods that require `&mut T` on them
35+ //! (like [`mem::swap`]).
3536//!
3637//! [`Pin`] can be used to wrap any pointer type, and as such it interacts with
3738//! [`Deref`] and [`DerefMut`]. A `Pin<P>` where `P: Deref` should be considered
221222//! reference we got later.
222223//!
223224//! On the other hand, if you decide *not* to offer any pinning projections, you
224- //! are free to `impl<T> Unpin for Container<T>`. In the standard library,
225+ //! are free to `impl<T> Unpin for Container<T>`. In the standard library,
225226//! this is done for all pointer types: `Box<T>: Unpin` holds for all `T`.
226227//! It makes sense to do this for pointer types, because moving the `Box<T>`
227228//! does not actually move the `T`: the `Box<T>` can be freely movable even if the `T`
@@ -341,7 +342,7 @@ impl<P: Deref> Pin<P> {
341342 /// pointed to by `pointer` is pinned, meaning that the data will not be moved or
342343 /// its storage invalidated until it gets dropped. If the constructed `Pin<P>` does
343344 /// not guarantee that the data `P` points to is pinned, constructing a
344- /// `Pin<P>` is unsafe. In particular,
345+ /// `Pin<P>` is unsafe.
345346 ///
346347 /// By using this method, you are making a promise about the `P::Deref` and
347348 /// `P::DerefMut` implementations, if they exist. Most importantly, they
@@ -353,9 +354,9 @@ impl<P: Deref> Pin<P> {
353354 /// must not be possible to obtain a `&mut P::Target` and then
354355 /// move out of that reference (using, for example [`mem::swap`]).
355356 ///
356- /// For example, calling `Pin::new_unchecked`
357- /// on an `&'a mut T` is unsafe because while you are able to pin it for the given
358- /// lifetime `'a`, you have no control over whether it is kept pinned once `'a` ends:
357+ /// For example, calling `Pin::new_unchecked` on an `&'a mut T` is unsafe because
358+ /// while you are able to pin it for the given lifetime `'a`, you have no control
359+ /// over whether it is kept pinned once `'a` ends:
359360 /// ```
360361 /// use std::mem;
361362 /// use std::pin::Pin;
@@ -395,10 +396,10 @@ impl<P: Deref> Pin<P> {
395396
396397 /// Gets a pinned shared reference from this pinned pointer.
397398 ///
398- /// This is a generic method to go from `&Pin<SmartPointer <T>>` to `Pin<&T>`.
399+ /// This is a generic method to go from `&Pin<Pointer <T>>` to `Pin<&T>`.
399400 /// It is safe because, as part of the contract of `Pin::new_unchecked`,
400- /// the pointee cannot move after `Pin<SmartPointer <T>>` got created.
401- /// "Malicious" implementations of `SmartPointer ::Deref` are likewise
401+ /// the pointee cannot move after `Pin<Pointer <T>>` got created.
402+ /// "Malicious" implementations of `Pointer ::Deref` are likewise
402403 /// ruled out by the contract of `Pin::new_unchecked`.
403404 #[ stable( feature = "pin" , since = "1.33.0" ) ]
404405 #[ inline( always) ]
@@ -410,10 +411,10 @@ impl<P: Deref> Pin<P> {
410411impl < P : DerefMut > Pin < P > {
411412 /// Gets a pinned mutable reference from this pinned pointer.
412413 ///
413- /// This is a generic method to go from `&mut Pin<SmartPointer <T>>` to `Pin<&mut T>`.
414+ /// This is a generic method to go from `&mut Pin<Pointer <T>>` to `Pin<&mut T>`.
414415 /// It is safe because, as part of the contract of `Pin::new_unchecked`,
415- /// the pointee cannot move after `Pin<SmartPointer <T>>` got created.
416- /// "Malicious" implementations of `SmartPointer ::DerefMut` are likewise
416+ /// the pointee cannot move after `Pin<Pointer <T>>` got created.
417+ /// "Malicious" implementations of `Pointer ::DerefMut` are likewise
417418 /// ruled out by the contract of `Pin::new_unchecked`.
418419 #[ stable( feature = "pin" , since = "1.33.0" ) ]
419420 #[ inline( always) ]
0 commit comments