Skip to content

Commit 665aa3e

Browse files
committed
minor edits
1 parent c489636 commit 665aa3e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/libcore/pin.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@
196196
//! type should that reference have? Is it `Pin<&mut Field>` or `&mut Field`?
197197
//! The same question arises with the fields of an enum, and also when considering
198198
//! container/wrapper types such as [`Vec<T>`], [`Box<T>`], or [`RefCell<T>`].
199-
//! Also, this question arises for both mutable and shared references, we just
200-
//! use the more common case of mutable references here for illustration.
199+
//! (This question applies to both mutable and shared references, we just
200+
//! use the more common case of mutable references here for illustration.)
201201
//!
202202
//! It turns out that it is actually up to the author of the data structure
203203
//! to decide whether the pinned projection for a particular field turns
@@ -214,22 +214,22 @@
214214
//!
215215
//! ## Pinning *is not* structural for `field`
216216
//!
217-
//! It may seem counter-intuitive that the field of a pinned struct is not pinned,
217+
//! It may seem counter-intuitive that the field of a pinned struct might not be pinned,
218218
//! but that is actually the easiest choice: if a `Pin<&mut Field>` is never created,
219219
//! nothing can go wrong! So, if you decide that some field does not have structural pinning,
220220
//! all you have to ensure is that you never create a pinned reference to that field.
221221
//!
222-
//! Then you may add a projection method that turns `Pin<&mut Struct>` into `Pin<&mut Field>`:
222+
//! Then you may add a projection method that turns `Pin<&mut Struct>` into `&mut Field`:
223223
//! ```rust,ignore
224224
//! impl Struct {
225-
//! fn get_field<'a>(self: Pin<&'a mut Self>) -> &'a mut Field {
225+
//! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> &'a mut Field {
226226
//! // This is okay because `field` is never considered pinned.
227227
//! unsafe { &mut self.get_unchecked_mut().field }
228228
//! }
229229
//! }
230230
//! ```
231231
//!
232-
//! You may also make make `Struct: Unpin` *even if* the type of `field`
232+
//! You may also `impl Unpin for Struct` *even if* the type of `field`
233233
//! is not `Unpin`. What that type thinks about pinning is just not relevant
234234
//! when no `Pin<&mut Field>` is ever created.
235235
//!
@@ -242,7 +242,7 @@
242242
//! witnessing that the field is pinned:
243243
//! ```rust,ignore
244244
//! impl Struct {
245-
//! fn get_field<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Field> {
245+
//! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Field> {
246246
//! // This is okay because `field` is pinned when `self` is.
247247
//! unsafe { self.map_unchecked_mut(|s| &mut s.field) }
248248
//! }
@@ -252,8 +252,8 @@
252252
//! However, structural pinning comes with a few extra requirements:
253253
//!
254254
//! 1. The struct must only be [`Unpin`] if all the structural fields are
255-
//! `Unpin`. This is the default, but `Unpin` is a safe trait, so it is your
256-
//! responsibility as the author of the struct *not* to add something like
255+
//! `Unpin`. This is the default, but `Unpin` is a safe trait, so as the author of
256+
//! the struct it is your responsibility *not* to add something like
257257
//! `impl<T> Unpin for Struct<T>`. (Notice that adding a projection operation
258258
//! requires unsafe code, so the fact that `Unpin` is a safe trait does not break
259259
//! the principle that you only have to worry about any of this if you use `unsafe`.)

0 commit comments

Comments
 (0)