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 168
168
//! you must treat Drop as implicitly taking `Pin<&mut Self>`.
169
169
//!
170
170
//! For example, you could implement `Drop` as follows:
171
- //! ```rust,ignore
171
+ //! ```rust,no_run
172
+ //! # use std::pin::Pin;
173
+ //! # struct Type { }
172
174
//! impl Drop for Type {
173
175
//! fn drop(&mut self) {
174
176
//! // `new_unchecked` is okay because we know this value is never used
220
222
//! all you have to ensure is that you never create a pinned reference to that field.
221
223
//!
222
224
//! 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 }
224
229
//! impl Struct {
225
230
//! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> &'a mut Field {
226
231
//! // This is okay because `field` is never considered pinned.
240
245
//!
241
246
//! This allows writing a projection that creates a `Pin<&mut Field>`, thus
242
247
//! 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 }
244
252
//! impl Struct {
245
253
//! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Field> {
246
254
//! // This is okay because `field` is pinned when `self` is.
You can’t perform that action at this time.
0 commit comments