28
28
html_root_url = "http://doc.rust-lang.org/nightly/" ) ]
29
29
30
30
#![ feature( unsafe_destructor) ]
31
+ #![ feature( unboxed_closures) ]
31
32
#![ allow( missing_docs) ]
32
33
33
34
extern crate alloc;
@@ -209,7 +210,7 @@ impl Arena {
209
210
}
210
211
211
212
#[ inline]
212
- fn alloc_copy < T > ( & self , op: || -> T ) -> & mut T {
213
+ fn alloc_copy < T , F > ( & self , op : F ) -> & mut T where F : FnOnce ( ) -> T {
213
214
unsafe {
214
215
let ptr = self . alloc_copy_inner ( mem:: size_of :: < T > ( ) ,
215
216
mem:: min_align_of :: < T > ( ) ) ;
@@ -263,7 +264,7 @@ impl Arena {
263
264
}
264
265
265
266
#[ inline]
266
- fn alloc_noncopy < T > ( & self , op: || -> T ) -> & mut T {
267
+ fn alloc_noncopy < T , F > ( & self , op : F ) -> & mut T where F : FnOnce ( ) -> T {
267
268
unsafe {
268
269
let tydesc = get_tydesc :: < T > ( ) ;
269
270
let ( ty_ptr, ptr) =
@@ -287,7 +288,7 @@ impl Arena {
287
288
/// Allocates a new item in the arena, using `op` to initialize the value,
288
289
/// and returns a reference to it.
289
290
#[ inline]
290
- pub fn alloc < T > ( & self , op: || -> T ) -> & mut T {
291
+ pub fn alloc < T , F > ( & self , op : F ) -> & mut T where F : FnOnce ( ) -> T {
291
292
unsafe {
292
293
if intrinsics:: needs_drop :: < T > ( ) {
293
294
self . alloc_noncopy ( op)
@@ -339,7 +340,7 @@ fn test_arena_destructors_fail() {
339
340
arena. alloc ( || { [ 0u8 , 1u8 , 2u8 ] } ) ;
340
341
}
341
342
// Now, panic while allocating
342
- arena. alloc :: < Rc < int > > ( || {
343
+ arena. alloc :: < Rc < int > , _ > ( || {
343
344
panic ! ( ) ;
344
345
} ) ;
345
346
}
0 commit comments