pub struct MemoryArena { /* private fields */ }Expand description
Arena allocator for fast temporary allocations.
Implementations§
Source§impl MemoryArena
impl MemoryArena
Sourcepub fn with_chunk_size(chunk_size: usize) -> Self
pub fn with_chunk_size(chunk_size: usize) -> Self
Create a new arena with specified chunk size.
Sourcepub fn allocate_aligned(&self, size: usize, align: usize) -> Option<NonNull<u8>>
pub fn allocate_aligned(&self, size: usize, align: usize) -> Option<NonNull<u8>>
Allocate aligned memory from the arena.
Sourcepub fn allocate_value<T>(&self, value: T) -> Option<&mut T>
pub fn allocate_value<T>(&self, value: T) -> Option<&mut T>
Allocate and initialize memory with a value.
Sourcepub fn allocate_slice<T: Copy>(&self, len: usize) -> Option<&mut [T]>
pub fn allocate_slice<T: Copy>(&self, len: usize) -> Option<&mut [T]>
Allocate a slice from the arena.
Sourcepub fn total_allocated(&self) -> usize
pub fn total_allocated(&self) -> usize
Get the total memory allocated by this arena.
Sourcepub fn total_used(&self) -> usize
pub fn total_used(&self) -> usize
Get the total memory used within allocated chunks.
Sourcepub fn total_remaining(&self) -> usize
pub fn total_remaining(&self) -> usize
Get the total remaining capacity across all allocated chunks.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MemoryArena
impl !RefUnwindSafe for MemoryArena
impl !Send for MemoryArena
impl !Sync for MemoryArena
impl Unpin for MemoryArena
impl UnsafeUnpin for MemoryArena
impl UnwindSafe for MemoryArena
Blanket Implementations§
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