pub struct VirtArena(/* private fields */);
Expand description
A memory arena which leverages the virtual memory system for allocating structures in a single contiguous memory region.
Implementations§
Source§impl VirtArena
impl VirtArena
Sourcepub unsafe fn alloc_zeroed<T: Sized>(&self) -> &mut T
pub unsafe fn alloc_zeroed<T: Sized>(&self) -> &mut T
Allocates a struct T
inside the arena and clears its memory to 0.
§Safety
Look into std::mem::zeroed for safety concerns.
Sourcepub unsafe fn alloc_slice_zeroed<T: Sized>(&self, count: usize) -> &mut [T]
pub unsafe fn alloc_slice_zeroed<T: Sized>(&self, count: usize) -> &mut [T]
Allocates a slice [T]
inside the arena and clears its memory to 0.
§Safety
Look into std::mem::zeroed for safety concerns.
Sourcepub fn alloc_uninit<T: Sized>(&self) -> &mut MaybeUninit<T>
pub fn alloc_uninit<T: Sized>(&self) -> &mut MaybeUninit<T>
Allocates memory for struct T
.
Sourcepub fn alloc_slice_uninit<T: Sized>(
&self,
count: usize,
) -> &mut [MaybeUninit<T>]
pub fn alloc_slice_uninit<T: Sized>( &self, count: usize, ) -> &mut [MaybeUninit<T>]
Allocates memory for slice [T]
.
Sourcepub fn alloc_with<T: Sized>(&self, fun: impl FnOnce() -> T) -> &mut T
pub fn alloc_with<T: Sized>(&self, fun: impl FnOnce() -> T) -> &mut T
Allocates a struct T
inside the arena and sets its
content to the output of fun
.
Sourcepub fn alloc_value<T: Sized>(&self, val: T) -> &mut T
pub fn alloc_value<T: Sized>(&self, val: T) -> &mut T
Allocates a struct T
inside the arena and moves val
into the allocation.
Sourcepub fn bytes_used(&self) -> usize
pub fn bytes_used(&self) -> usize
Returns the number of bytes currently allocated from the arena.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for VirtArena
impl !RefUnwindSafe for VirtArena
impl !Sync for VirtArena
impl Unpin for VirtArena
impl UnwindSafe for VirtArena
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