File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 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
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.
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.
You can’t perform that action at this time.
0 commit comments