File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 6
6
//! as moving an object with pointers to itself will invalidate them, which could cause undefined
7
7
//! behavior.
8
8
//!
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.
12
15
//!
13
16
//! By default, all types in Rust are movable. Rust allows passing all types by-value,
14
17
//! and common smart-pointer types such as [`Box<T>`] and `&mut T` allow replacing and
61
64
//!
62
65
//! # Example: self-referential struct
63
66
//!
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
+ //!
64
71
//! ```rust
65
72
//! use std::pin::Pin;
66
73
//! use std::marker::PhantomPinned;
You can’t perform that action at this time.
0 commit comments