Skip to content

Commit a36e9e2

Browse files
author
jiegec
committed
Handle AllocRef trait change in rust-lang/rust@d8e3557#diff-1b08d266cc36e37196b43a2251a5392b, fixing issue #2
1 parent b2fb16f commit a36e9e2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,16 @@ impl fmt::Debug for Heap {
201201
}
202202

203203
unsafe impl Alloc for Heap {
204+
#[rustversion::before(2020-03-03)]
204205
unsafe fn alloc(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr> {
205206
self.alloc(layout)
206207
}
207208

209+
#[rustversion::since(2020-03-03)]
210+
unsafe fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
211+
self.alloc(layout).map(|p| (p, layout.size()))
212+
}
213+
208214
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
209215
self.dealloc(ptr, layout)
210216
}

0 commit comments

Comments
 (0)