Skip to content

Commit 0cf7cd4

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 163308 b: refs/heads/snap-stage3 c: 1c5aac2 h: refs/heads/master v: v3
1 parent 8be745e commit 0cf7cd4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 9146a919b616e39e528e4d7100d16eef52f1f852
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 341e7bc08bfab8fa3abe851501d72336b8556275
4+
refs/heads/snap-stage3: 1c5aac2b308445c7a03cdf9ff4b5457f7adbf1fb
55
refs/heads/try: 20cbbffeefc1f35e2ea63afce7b42fbd79611d42
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libarena/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
html_root_url = "http://doc.rust-lang.org/nightly/")]
2929

3030
#![feature(unsafe_destructor)]
31+
#![feature(unboxed_closures)]
3132
#![allow(missing_docs)]
3233

3334
extern crate alloc;
@@ -209,7 +210,7 @@ impl Arena {
209210
}
210211

211212
#[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 {
213214
unsafe {
214215
let ptr = self.alloc_copy_inner(mem::size_of::<T>(),
215216
mem::min_align_of::<T>());
@@ -263,7 +264,7 @@ impl Arena {
263264
}
264265

265266
#[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 {
267268
unsafe {
268269
let tydesc = get_tydesc::<T>();
269270
let (ty_ptr, ptr) =
@@ -287,7 +288,7 @@ impl Arena {
287288
/// Allocates a new item in the arena, using `op` to initialize the value,
288289
/// and returns a reference to it.
289290
#[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 {
291292
unsafe {
292293
if intrinsics::needs_drop::<T>() {
293294
self.alloc_noncopy(op)
@@ -339,7 +340,7 @@ fn test_arena_destructors_fail() {
339340
arena.alloc(|| { [0u8, 1u8, 2u8] });
340341
}
341342
// Now, panic while allocating
342-
arena.alloc::<Rc<int>>(|| {
343+
arena.alloc::<Rc<int>, _>(|| {
343344
panic!();
344345
});
345346
}

0 commit comments

Comments
 (0)