pub struct ArenaRegion { /* private fields */ }Expand description
A contiguous slab of memory with a bump pointer.
Memory is never freed individually. Call reset to
reclaim the entire region at once.
Implementations§
Source§impl ArenaRegion
impl ArenaRegion
Sourcepub fn allocate(&mut self, size: usize) -> Option<(usize, usize)>
pub fn allocate(&mut self, size: usize) -> Option<(usize, usize)>
Bump-allocate size bytes aligned to ARENA_ALIGN.
Returns Some((start, end)) where the range [start, end) inside
slab is exclusively owned by the caller until reset is called.
Returns None if there is insufficient space.
Sourcepub fn remaining(&self) -> usize
pub fn remaining(&self) -> usize
Bytes still available for allocation (before alignment waste).
Sourcepub fn utilization(&self) -> f64
pub fn utilization(&self) -> f64
Fraction of capacity that has been allocated ([0.0, 1.0]).
Returns 0.0 for a zero-capacity region to avoid division by zero.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ArenaRegion
impl RefUnwindSafe for ArenaRegion
impl Send for ArenaRegion
impl Sync for ArenaRegion
impl Unpin for ArenaRegion
impl UnsafeUnpin for ArenaRegion
impl UnwindSafe for ArenaRegion
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more