Skip to content

Commit

Permalink
Fix Pin example from dangerous implicit autorefs
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Mar 30, 2024
1 parent 12f1ea5 commit 2b3fe45
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/core/src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@
//! [`Unmovable`] (from the example above), we could write an assignment function like so:
//!
//! ```
//! # #![feature(slice_ptr_len)]
//! # use std::pin::Pin;
//! # use std::marker::PhantomPinned;
//! # use std::ptr::NonNull;
Expand All @@ -676,7 +677,7 @@
//! let data_ptr = unpinned_src.data.as_ptr() as *const u8;
//! let slice_ptr = unpinned_src.slice.as_ptr() as *const u8;
//! let offset = slice_ptr.offset_from(data_ptr) as usize;
//! let len = (*unpinned_src.slice.as_ptr()).len();
//! let len = unpinned_src.slice.as_ptr().len();
//!
//! unpinned_self.slice = NonNull::from(&mut unpinned_self.data[offset..offset+len]);
//! }
Expand Down

0 comments on commit 2b3fe45

Please sign in to comment.