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: LevelThe 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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a, T: Copy> Copy for Allocation<'a, T>
Source§impl<'a, T: Debug> Debug for Allocation<'a, T>
impl<'a, T: Debug> Debug for Allocation<'a, T>
impl<'a, T: Eq> Eq for Allocation<'a, T>
Source§impl<'a, T: Ord> Ord for Allocation<'a, T>
impl<'a, T: Ord> Ord for Allocation<'a, T>
Source§fn cmp(&self, other: &Allocation<'a, T>) -> Ordering
fn cmp(&self, other: &Allocation<'a, T>) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'a, T: PartialEq> PartialEq for Allocation<'a, T>
impl<'a, T: PartialEq> PartialEq for Allocation<'a, T>
Source§fn eq(&self, other: &Allocation<'a, T>) -> bool
fn eq(&self, other: &Allocation<'a, T>) -> bool
self and other values to be equal, and is used by ==.