pub struct Arena<T> { /* private fields */ }Implementations§
Source§impl<T> Arena<T>
impl<T> Arena<T>
Sourcepub const fn with_capacity(initial_capacity: usize) -> Self
pub const fn with_capacity(initial_capacity: usize) -> Self
Creates a new empty arena with the specified initial capacity.
Sourcepub fn alloc(&self, value: T) -> &mut T
pub fn alloc(&self, value: T) -> &mut T
Allocates a new value in the arena and returns a mutable reference to it.
§Example
use simple_arena::Arena;
let arena = Arena::new();
let a = arena.alloc(1);
assert_eq!(*a, 1);Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the arena. O(n) time complexity.
§Example
use simple_arena::Arena;
let arena = Arena::new();
let a = arena.alloc(1);
let b = arena.alloc(2);
let c = arena.alloc(3);
assert_eq!(arena.len(), 3);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>where
T: UnwindSafe,
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