1 #![feature(allocator_api)]
3 use std::alloc::{AllocError, Allocator, Layout, System};
10 unsafe impl Allocator for Alloc {
11 fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
12 System.allocate(layout)
15 unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
16 System.deallocate(ptr, layout)
20 fn use_value(_: u32) {}
24 let boxed = Box::new_in(10, alloc.by_ref());
25 let theref = Box::leak(boxed);
27 //~^ ERROR cannot move out of `alloc` because it is borrowed