2021-04-25 12:44:30 +00:00
|
|
|
# vec-arena (deprecated)
|
2016-10-22 23:35:26 +00:00
|
|
|
|
2021-03-20 08:29:25 +00:00
|
|
|
[![Build](https://github.com/smol-rs/vec-arena/workflows/Build%20and%20test/badge.svg)](
|
|
|
|
https://github.com/smol-rs/vec-arena/actions)
|
2021-02-14 04:36:40 +00:00
|
|
|
[![License](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue.svg)](https://github.com/smol-rs/vec-arena)
|
2016-11-14 21:01:55 +00:00
|
|
|
[![Cargo](https://img.shields.io/crates/v/vec-arena.svg)](https://crates.io/crates/vec-arena)
|
|
|
|
[![Documentation](https://docs.rs/vec-arena/badge.svg)](https://docs.rs/vec-arena)
|
2016-10-26 10:45:23 +00:00
|
|
|
|
2021-04-25 12:44:30 +00:00
|
|
|
**This crate is now deprecated in favor of [slab](https://crates.io/crates/slab).**
|
|
|
|
|
2016-11-14 21:01:55 +00:00
|
|
|
#### What is this?
|
2016-10-26 10:45:23 +00:00
|
|
|
|
2016-11-14 21:01:55 +00:00
|
|
|
A simple object arena.
|
2016-10-25 16:50:15 +00:00
|
|
|
|
2016-11-14 21:01:55 +00:00
|
|
|
You want to build a doubly linked list? Or maybe a bidirectional tree? Perhaps an even more
|
|
|
|
complicated object graph?
|
2016-10-25 16:50:15 +00:00
|
|
|
|
2016-11-14 21:01:55 +00:00
|
|
|
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>`:
|
|
|
|
|
2020-12-26 14:47:13 +00:00
|
|
|
* [Doubly linked list](https://github.com/smol-rs/vec-arena/blob/master/examples/linked-list.rs)
|
|
|
|
* [Splay tree](https://github.com/smol-rs/vec-arena/blob/master/examples/splay-tree.rs)
|