From 6e3a3b1b67e9fd8cea5bf311fa6130ba1549a174 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 10 Mar 2019 20:29:45 +0100 Subject: [PATCH] read_ref doe not need to mutate thanks to @amosonn! --- personal/_posts/2018-04-05-a-formal-look-at-pinning.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/personal/_posts/2018-04-05-a-formal-look-at-pinning.md b/personal/_posts/2018-04-05-a-formal-look-at-pinning.md index 72dccc1..5e51e7c 100644 --- a/personal/_posts/2018-04-05-a-formal-look-at-pinning.md +++ b/personal/_posts/2018-04-05-a-formal-look-at-pinning.md @@ -68,11 +68,11 @@ impl SelfReferential { fn init(mut self: Pin) { let this : &mut SelfReferential = unsafe { Pin::get_mut(&mut self) }; // Set up self_ref to point to this.data. - this.self_ref = &mut this.data as *const i32; + this.self_ref = &this.data as *const i32; } - fn read_ref(mut self: Pin) -> Option { - let this : &mut SelfReferential = unsafe { Pin::get_mut(&mut self) }; + fn read_ref(self: Pin) -> Option { + let this : &SelfReferential = &*self; // Dereference self_ref if it is non-NULL. if this.self_ref == ptr::null() { None -- 2.30.2