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]

Create a new arena with an unspecified capacity.

Create a new arena with a known initial capacity.

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);

Get the number of objects currently placed in the arena.

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]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more