From 2eb074dff180743336b022144fae7e88ea849c4b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 16 Jun 2019 10:19:22 +0200 Subject: [PATCH] make example code typecheck at least --- src/libcore/pin.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs index 302e40a954f..ffea5cbf331 100644 --- a/src/libcore/pin.rs +++ b/src/libcore/pin.rs @@ -168,7 +168,9 @@ //! you must treat Drop as implicitly taking `Pin<&mut Self>`. //! //! For example, you could implement `Drop` as follows: -//! ```rust,ignore +//! ```rust,no_run +//! # use std::pin::Pin; +//! # struct Type { } //! impl Drop for Type { //! fn drop(&mut self) { //! // `new_unchecked` is okay because we know this value is never used @@ -220,7 +222,10 @@ //! all you have to ensure is that you never create a pinned reference to that field. //! //! Then you may add a projection method that turns `Pin<&mut Struct>` into `&mut Field`: -//! ```rust,ignore +//! ```rust,no_run +//! # use std::pin::Pin; +//! # type Field = i32; +//! # struct Struct { field: Field } //! impl Struct { //! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> &'a mut Field { //! // This is okay because `field` is never considered pinned. @@ -240,7 +245,10 @@ //! //! This allows writing a projection that creates a `Pin<&mut Field>`, thus //! witnessing that the field is pinned: -//! ```rust,ignore +//! ```rust,no_run +//! # use std::pin::Pin; +//! # type Field = i32; +//! # struct Struct { field: Field } //! impl Struct { //! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Field> { //! // This is okay because `field` is pinned when `self` is.