Struct Arena

Source
pub struct Arena<const SIZE: usize> { /* private fields */ }
Expand description

A fixed size arena that can be used to allocate memory for arbitrary types.

Implementations§

Source§

impl<'a, const SIZE: usize> Arena<SIZE>

Source

pub const fn new() -> Self

Create a new arena with a fixed size buffer of SIZE bytes.

Source

pub fn acquire_init_default<T: Init>(&'a self) -> Option<&'a T>
where T::InitArg: Default,

acquire a reference to a value of type T that can be initialized with the Init trait, using the default value of the InitArg. This is useful for types that require initialization and the init arg is Default.

Source

pub fn acquire_init<T: Init>(&'a self, arg: T::InitArg) -> Option<&'a T>

acquire a reference to a value of type T that can be initialized with the Init trait, using a given InitArg. This is useful for types that require initialization.

Source

pub fn acquire_default<T: Default>(&'a self) -> Option<&'a T>

acquire a reference to a value of type T that is initialized with it’s default value. This is useful for types that do not require initialization.

Source

pub fn acquire<T>(&'a self, val: T) -> Option<&'a T>

acquire a reference to a value of type T that is initialized with the given value. This is useful for types that do not require initialization.

Trait Implementations§

Source§

impl<const SIZE: usize> Default for Arena<SIZE>

Source§

fn default() -> Self

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

impl<const SIZE: usize> Drop for Arena<SIZE>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<const SIZE: usize> Send for Arena<SIZE>

Source§

impl<const SIZE: usize> Sync for Arena<SIZE>

Auto Trait Implementations§

§

impl<const SIZE: usize> !Freeze for Arena<SIZE>

§

impl<const SIZE: usize> !RefUnwindSafe for Arena<SIZE>

§

impl<const SIZE: usize> Unpin for Arena<SIZE>

§

impl<const SIZE: usize> UnwindSafe for Arena<SIZE>

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.