rc_arena 0.1.0

An arena which yields reference counted pointers to the underlying objects
Documentation
  • Coverage
  • 100%
    8 out of 8 items documented3 out of 8 items with examples
  • Size
  • Source code size: 8.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.81 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • Documentation
  • ebfull/rc_arena
    3 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ebfull

rc_arena Build status Crates.io

Documentation

Alternative to typed-arena that instead returns reference counted pointers to the underlying objects, avoiding lifetime bounds but incurring a runtime penalty. Useful when you wish to create a large number of Rc<T> objects but want them close together in memory, or wish to avoid expensive allocations.

As with all arenas, it's also useful if you don't care about deallocation until after you're done with the entire collection of objects.

How do I use it?

Cargo.toml:

[dependencies]
rc_arena = "0.1.0"

Code:

extern crate rc_arena;

use rc_arena::Arena;

fn main() {
	let arena = Arena::new();
	
	let foo = arena.alloc([1,2,3,4]);
	let bar = arena.alloc([5,6,7,8]);
	let baz = foo.clone();

	assert_eq!(foo[0], 1);
	assert_eq!(bar[0], 5);
	assert_eq!(baz[0], 1);
}

See also