Struct rc_arena::Arena
[−]
[src]
pub struct Arena<T> { /* fields omitted */ }
A typed arena that provides reference-counted pointers to its underlying objects.
Methods
impl<T> Arena<T>
[src]
fn new() -> Arena<T>
Create a new arena with an unspecified capacity.
fn with_capacity(n: usize) -> Arena<T>
Create a new arena with a known initial capacity.
fn alloc(&self, value: T) -> Rc<T>
Store an object in the arena, returning a reference counted pointer to it.
use rc_arena::Arena; let arena = Arena::new(); let foo = arena.alloc([0; 256]); let bar = arena.alloc([1; 256]); let baz = bar.clone(); assert_eq!(foo[0], 0); assert_eq!(bar[0], 1); assert_eq!(baz[0], 1);
fn len(&self) -> usize
Get the number of objects currently placed in the arena.
fn each<F: for<'a> FnMut(&'a Rc<T>)>(&self, f: F)
Iterate over the objects in the arena, accepting a closure which will be passed a reference to the Rc of the object. This may be deprecated in favor of a (safe) iterator API in the future.
This will always iterate in the order that the objects were allocated.
use rc_arena::Arena; let arena = Arena::new(); arena.alloc("Hello,"); arena.alloc(" "); arena.alloc("world!\n"); arena.each(|obj| { print!("{}", obj); });
Trait Implementations
impl<T: Clone> Clone for Arena<T>
[src]
fn clone(&self) -> Arena<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more