@@ -28,7 +28,7 @@ For instance, a custom implementation of `Box` might write `Drop` like this:
2828``` rust
2929#![feature(ptr_internals, allocator_api)]
3030
31- use std :: alloc :: {AllocRef , Global , GlobalAlloc , Layout };
31+ use std :: alloc :: {Allocator , Global , GlobalAlloc , Layout };
3232use std :: mem;
3333use std :: ptr :: {drop_in_place, NonNull , Unique };
3434
@@ -39,7 +39,7 @@ impl<T> Drop for Box<T> {
3939 unsafe {
4040 drop_in_place (self . ptr. as_ptr ());
4141 let c : NonNull <T > = self . ptr. into ();
42- Global . dealloc (c . cast (), Layout :: new :: <T >())
42+ Global . deallocate (c . cast (), Layout :: new :: <T >())
4343 }
4444 }
4545}
@@ -55,7 +55,7 @@ However this wouldn't work:
5555``` rust
5656#![feature(allocator_api, ptr_internals)]
5757
58- use std :: alloc :: {AllocRef , Global , GlobalAlloc , Layout };
58+ use std :: alloc :: {Allocator , Global , GlobalAlloc , Layout };
5959use std :: ptr :: {drop_in_place, Unique , NonNull };
6060use std :: mem;
6161
@@ -66,7 +66,7 @@ impl<T> Drop for Box<T> {
6666 unsafe {
6767 drop_in_place (self . ptr. as_ptr ());
6868 let c : NonNull <T > = self . ptr. into ();
69- Global . dealloc (c . cast (), Layout :: new :: <T >());
69+ Global . deallocate (c . cast (), Layout :: new :: <T >());
7070 }
7171 }
7272}
@@ -79,7 +79,7 @@ impl<T> Drop for SuperBox<T> {
7979 // Hyper-optimized: deallocate the box's contents for it
8080 // without `drop`ing the contents
8181 let c : NonNull <T > = self . my_box. ptr. into ();
82- Global . dealloc (c . cast :: <u8 >(), Layout :: new :: <T >());
82+ Global . deallocate (c . cast :: <u8 >(), Layout :: new :: <T >());
8383 }
8484 }
8585}
@@ -128,7 +128,7 @@ of Self during `drop` is to use an Option:
128128``` rust
129129#![feature(allocator_api, ptr_internals)]
130130
131- use std :: alloc :: {AllocRef , GlobalAlloc , Global , Layout };
131+ use std :: alloc :: {Allocator , GlobalAlloc , Global , Layout };
132132use std :: ptr :: {drop_in_place, Unique , NonNull };
133133use std :: mem;
134134
@@ -139,7 +139,7 @@ impl<T> Drop for Box<T> {
139139 unsafe {
140140 drop_in_place (self . ptr. as_ptr ());
141141 let c : NonNull <T > = self . ptr. into ();
142- Global . dealloc (c . cast (), Layout :: new :: <T >());
142+ Global . deallocate (c . cast (), Layout :: new :: <T >());
143143 }
144144 }
145145}
@@ -154,7 +154,7 @@ impl<T> Drop for SuperBox<T> {
154154 // field as `None` to prevent Rust from trying to Drop it.
155155 let my_box = self . my_box. take (). unwrap ();
156156 let c : NonNull <T > = my_box . ptr. into ();
157- Global . dealloc (c . cast (), Layout :: new :: <T >());
157+ Global . deallocate (c . cast (), Layout :: new :: <T >());
158158 mem :: forget (my_box );
159159 }
160160 }
0 commit comments