Skip to content

Commit 7aac3e0

Browse files
committed
pin docs: add some forward references
1 parent 3fbed17 commit 7aac3e0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

library/core/src/pin.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
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
@@ -61,6 +64,10 @@
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;

0 commit comments

Comments
 (0)