diff options
| author | Ralf Jung <post@ralfj.de> | 2019-06-16 10:19:22 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-06-16 10:19:22 +0200 |
| commit | 2eb074dff180743336b022144fae7e88ea849c4b (patch) | |
| tree | 8dfc2da2a0e300644989f8ffd856fef7dcd82f38 /src/libcore | |
| parent | 86e283a1b70005e7d0f31131fe17ffe1fb1dcd79 (diff) | |
| download | rust-2eb074dff180743336b022144fae7e88ea849c4b.tar.gz rust-2eb074dff180743336b022144fae7e88ea849c4b.zip | |
make example code typecheck at least
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/pin.rs | 14 |
1 files 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. |
