@@ -208,13 +208,13 @@ impl Arena {
208
208
}
209
209
210
210
#[ inline]
211
- fn alloc_copy < T > ( & self , op: || -> T ) -> & T {
211
+ fn alloc_copy < T > ( & self , op: || -> T ) -> & mut T {
212
212
unsafe {
213
213
let ptr = self . alloc_copy_inner ( mem:: size_of :: < T > ( ) ,
214
214
mem:: min_align_of :: < T > ( ) ) ;
215
215
let ptr = ptr as * mut T ;
216
216
ptr:: write ( & mut ( * ptr) , op ( ) ) ;
217
- return & * ptr;
217
+ return & mut * ptr;
218
218
}
219
219
}
220
220
@@ -262,7 +262,7 @@ impl Arena {
262
262
}
263
263
264
264
#[ inline]
265
- fn alloc_noncopy < T > ( & self , op: || -> T ) -> & T {
265
+ fn alloc_noncopy < T > ( & self , op: || -> T ) -> & mut T {
266
266
unsafe {
267
267
let tydesc = get_tydesc :: < T > ( ) ;
268
268
let ( ty_ptr, ptr) =
@@ -279,14 +279,14 @@ impl Arena {
279
279
// the object is there.
280
280
* ty_ptr = bitpack_tydesc_ptr ( tydesc, true ) ;
281
281
282
- return & * ptr;
282
+ return & mut * ptr;
283
283
}
284
284
}
285
285
286
286
/// Allocates a new item in the arena, using `op` to initialize the value,
287
287
/// and returns a reference to it.
288
288
#[ inline]
289
- pub fn alloc < T > ( & self , op: || -> T ) -> & T {
289
+ pub fn alloc < T > ( & self , op: || -> T ) -> & mut T {
290
290
unsafe {
291
291
if intrinsics:: needs_drop :: < T > ( ) {
292
292
self . alloc_noncopy ( op)
@@ -458,12 +458,12 @@ impl<T> TypedArena<T> {
458
458
459
459
/// Allocates an object in the `TypedArena`, returning a reference to it.
460
460
#[ inline]
461
- pub fn alloc ( & self , object : T ) -> & T {
461
+ pub fn alloc ( & self , object : T ) -> & mut T {
462
462
if self . ptr == self . end {
463
463
self . grow ( )
464
464
}
465
465
466
- let ptr: & T = unsafe {
466
+ let ptr: & mut T = unsafe {
467
467
let ptr: & mut T = mem:: transmute ( self . ptr ) ;
468
468
ptr:: write ( ptr, object) ;
469
469
self . ptr . set ( self . ptr . get ( ) . offset ( 1 ) ) ;
0 commit comments