pub struct Allocation<'a, T = u8> {
pub ptr: NonNull<T>,
pub lifetime: AllocTime<'a>,
pub level: Level,
}
Expand description
A successful allocation and current Level
.
Fields§
§ptr: NonNull<T>
Pointer to the uninitialized region with specified layout.
lifetime: AllocTime<'a>
The lifetime of the allocation.
level: Level
The observed amount of consumed bytes after the allocation.
Implementations§
Source§impl<'alloc, T> Allocation<'alloc, T>
impl<'alloc, T> Allocation<'alloc, T>
Sourcepub unsafe fn leak(self, val: T) -> &'alloc mut T
pub unsafe fn leak(self, val: T) -> &'alloc mut T
Write a value into the allocation and leak it.
§Safety
Must have been allocated for a layout that fits the layout of T previously. The pointer must not be aliased.
§Usage
Consider the alternative Bump::leak
to safely allocate and directly leak a value.
Sourcepub unsafe fn boxed(self, val: T) -> LeakBox<'alloc, T>
pub unsafe fn boxed(self, val: T) -> LeakBox<'alloc, T>
Write a value into the allocation and own it.
§Safety
Must have been allocated for a layout that fits the layout of T previously. The pointer must not be aliased.
§Usage
Consider the alternative Bump::leak
to safely allocate and directly leak a value.
Sourcepub unsafe fn uninit(self) -> &'alloc mut MaybeUninit<T>
pub unsafe fn uninit(self) -> &'alloc mut MaybeUninit<T>
Convert this into a mutable reference to an uninitialized slot.
§Safety
Must have been allocated for a layout that fits the layout of T previously.
Trait Implementations§
Source§impl<'a, T: Clone> Clone for Allocation<'a, T>
impl<'a, T: Clone> Clone for Allocation<'a, T>
Source§fn clone(&self) -> Allocation<'a, T>
fn clone(&self) -> Allocation<'a, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more