better section title
[web.git] / ralf / _posts / 2018-04-05-a-formal-look-at-pinning.md
index 72dccc18d5cbea0fd8931830160fb8335643dab3..5e51e7c747dbc01a0307a5f343b28e21cd27997c 100644 (file)
@@ -68,11 +68,11 @@ impl SelfReferential {
     fn init(mut self: Pin<SelfReferential>) {
         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<SelfReferential>) -> Option<i32> {
-        let this : &mut SelfReferential = unsafe { Pin::get_mut(&mut self) };
+    fn read_ref(self: Pin<SelfReferential>) -> Option<i32> {
+        let this : &SelfReferential = &*self;
         // Dereference self_ref if it is non-NULL.
         if this.self_ref == ptr::null() {
             None