Skip to content

Commit 2eb074d

Browse files
committed
make example code typecheck at least
1 parent 86e283a commit 2eb074d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/libcore/pin.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@
168168
//! you must treat Drop as implicitly taking `Pin<&mut Self>`.
169169
//!
170170
//! For example, you could implement `Drop` as follows:
171-
//! ```rust,ignore
171+
//! ```rust,no_run
172+
//! # use std::pin::Pin;
173+
//! # struct Type { }
172174
//! impl Drop for Type {
173175
//! fn drop(&mut self) {
174176
//! // `new_unchecked` is okay because we know this value is never used
@@ -220,7 +222,10 @@
220222
//! all you have to ensure is that you never create a pinned reference to that field.
221223
//!
222224
//! Then you may add a projection method that turns `Pin<&mut Struct>` into `&mut Field`:
223-
//! ```rust,ignore
225+
//! ```rust,no_run
226+
//! # use std::pin::Pin;
227+
//! # type Field = i32;
228+
//! # struct Struct { field: Field }
224229
//! impl Struct {
225230
//! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> &'a mut Field {
226231
//! // This is okay because `field` is never considered pinned.
@@ -240,7 +245,10 @@
240245
//!
241246
//! This allows writing a projection that creates a `Pin<&mut Field>`, thus
242247
//! witnessing that the field is pinned:
243-
//! ```rust,ignore
248+
//! ```rust,no_run
249+
//! # use std::pin::Pin;
250+
//! # type Field = i32;
251+
//! # struct Struct { field: Field }
244252
//! impl Struct {
245253
//! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Field> {
246254
//! // This is okay because `field` is pinned when `self` is.

0 commit comments

Comments
 (0)