]> git.proxmox.com Git - rustc.git/blobdiff - src/doc/nomicon/src/destructors.md
New upstream version 1.19.0+dfsg1
[rustc.git] / src / doc / nomicon / src / destructors.md
index 8c395fe3dc947ebbf0ec40405a8f77a1732a0156..6c7b2c9d098af67e8cd8f7d9b510b79b0a082869 100644 (file)
@@ -40,8 +40,8 @@ struct Box<T>{ ptr: Unique<T> }
 impl<T> Drop for Box<T> {
     fn drop(&mut self) {
         unsafe {
-            drop_in_place(*self.ptr);
-            heap::deallocate((*self.ptr) as *mut u8,
+            drop_in_place(self.ptr.as_ptr());
+            heap::deallocate(self.ptr.as_ptr() as *mut u8,
                              mem::size_of::<T>(),
                              mem::align_of::<T>());
         }
@@ -71,8 +71,8 @@ struct Box<T>{ ptr: Unique<T> }
 impl<T> Drop for Box<T> {
     fn drop(&mut self) {
         unsafe {
-            drop_in_place(*self.ptr);
-            heap::deallocate((*self.ptr) as *mut u8,
+            drop_in_place(self.ptr.as_ptr());
+            heap::deallocate(self.ptr.as_ptr() as *mut u8,
                              mem::size_of::<T>(),
                              mem::align_of::<T>());
         }
@@ -86,7 +86,7 @@ impl<T> Drop for SuperBox<T> {
         unsafe {
             // Hyper-optimized: deallocate the box's contents for it
             // without `drop`ing the contents
-            heap::deallocate((*self.my_box.ptr) as *mut u8,
+            heap::deallocate(self.my_box.ptr.as_ptr() as *mut u8,
                              mem::size_of::<T>(),
                              mem::align_of::<T>());
         }
@@ -149,8 +149,8 @@ struct Box<T>{ ptr: Unique<T> }
 impl<T> Drop for Box<T> {
     fn drop(&mut self) {
         unsafe {
-            drop_in_place(*self.ptr);
-            heap::deallocate((*self.ptr) as *mut u8,
+            drop_in_place(self.ptr.as_ptr());
+            heap::deallocate(self.ptr.as_ptr() as *mut u8,
                              mem::size_of::<T>(),
                              mem::align_of::<T>());
         }
@@ -166,7 +166,7 @@ impl<T> Drop for SuperBox<T> {
             // without `drop`ing the contents. Need to set the `box`
             // field as `None` to prevent Rust from trying to Drop it.
             let my_box = self.my_box.take().unwrap();
-            heap::deallocate((*my_box.ptr) as *mut u8,
+            heap::deallocate(my_box.ptr.as_ptr() as *mut u8,
                              mem::size_of::<T>(),
                              mem::align_of::<T>());
             mem::forget(my_box);