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

#588 in Memory management

Download history 1994/week @ 2024-07-21 1879/week @ 2024-07-28 1720/week @ 2024-08-04 3234/week @ 2024-08-11 1913/week @ 2024-08-18 2605/week @ 2024-08-25 2231/week @ 2024-09-01 1785/week @ 2024-09-08 1722/week @ 2024-09-15 2449/week @ 2024-09-22 1733/week @ 2024-09-29 584/week @ 2024-10-06 1441/week @ 2024-10-13 1510/week @ 2024-10-20 1699/week @ 2024-10-27 1798/week @ 2024-11-03

6,467 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