Struct VirtArena

Source
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

Source

pub fn alloc(&self, layout: Layout) -> NonNull<u8>

Allocates a memory for the given layout.

Source

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.

Source

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.

Source

pub fn alloc_uninit<T: Sized>(&self) -> &mut MaybeUninit<T>

Allocates memory for struct T.

Source

pub fn alloc_slice_uninit<T: Sized>( &self, count: usize, ) -> &mut [MaybeUninit<T>]

Allocates memory for slice [T].

Source

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.

Source

pub fn alloc_value<T: Sized>(&self, val: T) -> &mut T

Allocates a struct T inside the arena and moves val into the allocation.

Source

pub fn bytes_used(&self) -> usize

Returns the number of bytes currently allocated from the arena.

Source

pub fn reset(&mut self)

Restes the arena storage, Invalidating all the references allocated. This method does not run the destructors! Those need to be run manually.

Trait Implementations§

Source§

impl Default for VirtArena

Source§

fn default() -> VirtArena

Returns the “default value” for a type. Read more
Source§

impl Send for VirtArena

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.