13 releases (3 stable)

1.2.0 May 8, 2021
1.1.0 Mar 20, 2021
1.0.0 Sep 7, 2020
0.5.2 Aug 20, 2020
0.1.1 Nov 14, 2016

#829 in Memory management

Download history 1927/week @ 2025-01-21 2431/week @ 2025-01-28 6572/week @ 2025-02-04 2120/week @ 2025-02-11 1449/week @ 2025-02-18 1951/week @ 2025-02-25 1108/week @ 2025-03-04 2578/week @ 2025-03-11 2824/week @ 2025-03-18 2152/week @ 2025-03-25 1039/week @ 2025-04-01 1611/week @ 2025-04-08 1346/week @ 2025-04-15 2973/week @ 2025-04-22 3224/week @ 2025-04-29 2423/week @ 2025-05-06

10,393 downloads per month
Used in 20 crates (via synchrotron)

Apache-2.0 OR MIT

23KB
304 lines

vec-arena (deprecated)

Build License Cargo Documentation

This crate is now deprecated in favor of slab.

What is this?

A simple object arena.

You want to build a doubly linked list? Or maybe a bidirectional tree? Perhaps an even more complicated object graph?

Managing ownership and lifetimes might be tough then. Your options boil down to:

  1. Use unsafe code to escape Rust's ownership rules.
  2. Wrap every object in Rc<RefCell<T>>.
  3. Use Vec<T> to store objects, then access them using indices.

If the last option seems most appealing to you, perhaps Arena<T> is for you. It will provide a more convenient API than a plain Vec<T>.

Examples

Some data structures built using Arena<T>:

No runtime deps