Skip to main content

IArena

Trait IArena 

Source
pub trait IArena<T> {
    // Required methods
    fn alloc(&mut self, value: T) -> Idx<T>;
    fn free(&mut self, id: Idx<T>) -> T;
    fn get(&self, id: Idx<T>) -> &T;
    fn get_mut(&mut self, id: Idx<T>) -> &mut T;
}
Expand description

Arena for allocating and managing items.

Required Methods§

Source

fn alloc(&mut self, value: T) -> Idx<T>

Allocate a new item, returning its index.

Source

fn free(&mut self, id: Idx<T>) -> T

Free an item, returning it.

§Panics

Panics if the index is invalid or already freed.

Source

fn get(&self, id: Idx<T>) -> &T

Get a reference to an item.

§Panics

Panics if the index is invalid or freed.

Source

fn get_mut(&mut self, id: Idx<T>) -> &mut T

Get a mutable reference to an item.

§Panics

Panics if the index is invalid or freed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, const N: usize> IArena<T> for VArena<T, N>

Source§

impl<T> IArena<T> for LArena<T>