@@ -44,23 +44,6 @@ fn outline<F: FnOnce() -> R, R>(f: F) -> R {
44
44
f ( )
45
45
}
46
46
47
- /// An arena that can hold objects of only one type.
48
- pub struct TypedArena < T > {
49
- /// A pointer to the next object to be allocated.
50
- ptr : Cell < * mut T > ,
51
-
52
- /// A pointer to the end of the allocated area. When this pointer is
53
- /// reached, a new chunk is allocated.
54
- end : Cell < * mut T > ,
55
-
56
- /// A vector of arena chunks.
57
- chunks : RefCell < Vec < ArenaChunk < T > > > ,
58
-
59
- /// Marker indicating that dropping the arena causes its owned
60
- /// instances of `T` to be dropped.
61
- _own : PhantomData < T > ,
62
- }
63
-
64
47
struct ArenaChunk < T = u8 > {
65
48
/// The raw storage for the arena chunk.
66
49
storage : NonNull < [ MaybeUninit < T > ] > ,
@@ -130,6 +113,23 @@ impl<T> ArenaChunk<T> {
130
113
const PAGE : usize = 4096 ;
131
114
const HUGE_PAGE : usize = 2 * 1024 * 1024 ;
132
115
116
+ /// An arena that can hold objects of only one type.
117
+ pub struct TypedArena < T > {
118
+ /// A pointer to the next object to be allocated.
119
+ ptr : Cell < * mut T > ,
120
+
121
+ /// A pointer to the end of the allocated area. When this pointer is
122
+ /// reached, a new chunk is allocated.
123
+ end : Cell < * mut T > ,
124
+
125
+ /// A vector of arena chunks.
126
+ chunks : RefCell < Vec < ArenaChunk < T > > > ,
127
+
128
+ /// Marker indicating that dropping the arena causes its owned
129
+ /// instances of `T` to be dropped.
130
+ _own : PhantomData < T > ,
131
+ }
132
+
133
133
impl < T > Default for TypedArena < T > {
134
134
/// Creates a new `TypedArena`.
135
135
fn default ( ) -> TypedArena < T > {
0 commit comments