Struct static_alloc::bump::Allocation
source · 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 moresource§impl<'a, T: Debug> Debug for Allocation<'a, T>
impl<'a, T: Debug> Debug 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 · 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 ==
.source§impl<'a, T: PartialOrd> PartialOrd for Allocation<'a, T>
impl<'a, T: PartialOrd> PartialOrd for Allocation<'a, T>
source§fn partial_cmp(&self, other: &Allocation<'a, T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Allocation<'a, T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more