full implementation for nullable unwrapped

This commit is contained in:
Folkert 2023-04-05 15:02:53 +02:00
parent 64f96c4182
commit 3151a08edb
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
3 changed files with 169 additions and 11 deletions

View file

@ -44,6 +44,15 @@ impl<T> RocBox<T> {
Self { contents }
}
/// # Safety
///
/// The box must be unique in order to leak it safely
pub unsafe fn leak(self) -> *mut T {
let ptr = self.contents.as_ptr() as *mut T;
core::mem::forget(self);
ptr
}
#[inline(always)]
fn alloc_alignment() -> usize {
mem::align_of::<T>().max(mem::align_of::<Storage>())