rc_arena

Crates.iorc_arena
lib.rsrc_arena
version0.1.0
sourcesrc
created_at2015-08-29 23:41:07.04895
updated_at2015-12-11 23:55:29.371301
descriptionAn arena which yields reference counted pointers to the underlying objects
homepagehttps://github.com/ebfull/rc_arena
repositoryhttps://github.com/ebfull/rc_arena
max_upload_size
id2957
size8,356
(ebfull)

documentation

https://ebfull.github.io/rc_arena/

README

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

Commit count: 4

cargo fmt