File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 66//! as moving an object with pointers to itself will invalidate them, which could cause undefined
77//! behavior.
88//!
9- //! A [`Pin<P>`] ensures that the pointee of any pointer type `P` has a stable location in memory,
10- //! meaning it cannot be moved elsewhere and its memory cannot be deallocated
11- //! until it gets dropped. We say that the pointee is "pinned".
9+ //! At a high level, a [`Pin<P>`] ensures that the pointee of any pointer type
10+ //! `P` has a stable location in memory, meaning it cannot be moved elsewhere
11+ //! and its memory cannot be deallocated until it gets dropped. We say that the
12+ //! pointee is "pinned". Things get more subtle when discussing types that
13+ //! combine pinned with non-pinned data; [see below](#projections-and-structural-pinning)
14+ //! for more details.
1215//!
1316//! By default, all types in Rust are movable. Rust allows passing all types by-value,
1417//! and common smart-pointer types such as [`Box<T>`] and `&mut T` allow replacing and
6164//!
6265//! # Example: self-referential struct
6366//!
67+ //! Before we go into more details to explain the guarantees and choices
68+ //! associated with `Pin<T>`, we discuss some examples for how it might be used.
69+ //! Feel free to [skip to where the theoretical discussion continues](#drop-guarantee).
70+ //!
6471//! ```rust
6572//! use std::pin::Pin;
6673//! use std::marker::PhantomPinned;
You can’t perform that action at this time.
0 commit comments