@@ -28,7 +28,7 @@ For instance, a custom implementation of `Box` might write `Drop` like this:
28
28
``` rust
29
29
#![feature(ptr_internals, allocator_api)]
30
30
31
- use std :: alloc :: {AllocRef , Global , GlobalAlloc , Layout };
31
+ use std :: alloc :: {Allocator , Global , GlobalAlloc , Layout };
32
32
use std :: mem;
33
33
use std :: ptr :: {drop_in_place, NonNull , Unique };
34
34
@@ -39,7 +39,7 @@ impl<T> Drop for Box<T> {
39
39
unsafe {
40
40
drop_in_place (self . ptr. as_ptr ());
41
41
let c : NonNull <T > = self . ptr. into ();
42
- Global . dealloc (c . cast (), Layout :: new :: <T >())
42
+ Global . deallocate (c . cast (), Layout :: new :: <T >())
43
43
}
44
44
}
45
45
}
@@ -55,7 +55,7 @@ However this wouldn't work:
55
55
``` rust
56
56
#![feature(allocator_api, ptr_internals)]
57
57
58
- use std :: alloc :: {AllocRef , Global , GlobalAlloc , Layout };
58
+ use std :: alloc :: {Allocator , Global , GlobalAlloc , Layout };
59
59
use std :: ptr :: {drop_in_place, Unique , NonNull };
60
60
use std :: mem;
61
61
@@ -66,7 +66,7 @@ impl<T> Drop for Box<T> {
66
66
unsafe {
67
67
drop_in_place (self . ptr. as_ptr ());
68
68
let c : NonNull <T > = self . ptr. into ();
69
- Global . dealloc (c . cast (), Layout :: new :: <T >());
69
+ Global . deallocate (c . cast (), Layout :: new :: <T >());
70
70
}
71
71
}
72
72
}
@@ -79,7 +79,7 @@ impl<T> Drop for SuperBox<T> {
79
79
// Hyper-optimized: deallocate the box's contents for it
80
80
// without `drop`ing the contents
81
81
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 >());
83
83
}
84
84
}
85
85
}
@@ -128,7 +128,7 @@ of Self during `drop` is to use an Option:
128
128
``` rust
129
129
#![feature(allocator_api, ptr_internals)]
130
130
131
- use std :: alloc :: {AllocRef , GlobalAlloc , Global , Layout };
131
+ use std :: alloc :: {Allocator , GlobalAlloc , Global , Layout };
132
132
use std :: ptr :: {drop_in_place, Unique , NonNull };
133
133
use std :: mem;
134
134
@@ -139,7 +139,7 @@ impl<T> Drop for Box<T> {
139
139
unsafe {
140
140
drop_in_place (self . ptr. as_ptr ());
141
141
let c : NonNull <T > = self . ptr. into ();
142
- Global . dealloc (c . cast (), Layout :: new :: <T >());
142
+ Global . deallocate (c . cast (), Layout :: new :: <T >());
143
143
}
144
144
}
145
145
}
@@ -154,7 +154,7 @@ impl<T> Drop for SuperBox<T> {
154
154
// field as `None` to prevent Rust from trying to Drop it.
155
155
let my_box = self . my_box. take (). unwrap ();
156
156
let c : NonNull <T > = my_box . ptr. into ();
157
- Global . dealloc (c . cast (), Layout :: new :: <T >());
157
+ Global . deallocate (c . cast (), Layout :: new :: <T >());
158
158
mem :: forget (my_box );
159
159
}
160
160
}
0 commit comments