From 2b3fe4509bd60ad1c62f8a3f82de699b94d494c2 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sat, 30 Mar 2024 17:57:23 +0100 Subject: [PATCH] Fix Pin example from dangerous implicit autorefs --- library/core/src/pin.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index e843a5d5790d2..0b1e35a6cead6 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -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; @@ -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]); //! }