pub struct Arena<T> { /* private fields */ }Expand description
A bump allocator for stable, arena-allocated references.
Values allocated in an arena live until the arena is dropped or reset. References remain valid across subsequent allocations, making this ideal for AST nodes that reference each other.
Implementations§
Source§impl<T> Arena<T>
impl<T> Arena<T>
Sourcepub fn alloc(&self, value: T) -> &T
pub fn alloc(&self, value: T) -> &T
Allocates a value and returns a reference valid for the arena’s lifetime.
Sourcepub fn alloc_slice<I>(&self, items: I) -> &[T]
pub fn alloc_slice<I>(&self, items: I) -> &[T]
Allocates a slice from an iterator.
The iterator must implement ExactSizeIterator so the arena can
pre-allocate the correct amount of space.
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for Arena<T>
impl<T> !RefUnwindSafe for Arena<T>
impl<T> Send for Arena<T>where
T: Send,
impl<T> !Sync for Arena<T>
impl<T> Unpin for Arena<T>where
T: Unpin,
impl<T> !UnwindSafe for Arena<T>
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