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

#605 in Memory management

Download history 1879/week @ 2023-12-15 1460/week @ 2023-12-22 1078/week @ 2023-12-29 1769/week @ 2024-01-05 1809/week @ 2024-01-12 1826/week @ 2024-01-19 1374/week @ 2024-01-26 1023/week @ 2024-02-02 1884/week @ 2024-02-09 2165/week @ 2024-02-16 1739/week @ 2024-02-23 1920/week @ 2024-03-01 2033/week @ 2024-03-08 1553/week @ 2024-03-15 2470/week @ 2024-03-22 2024/week @ 2024-03-29

8,402 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