Expand description
Provides a super-simple Arena
collection that maps EntryId
s to values of some type.
When you insert an item, you get the corresponding ID, and that ID won’t change for as long as the item stays in the Arena. You can then retrieve or remove an item by its ID. This is useful for building graph-like data structures (trees, linked lists, or more flexible graphs) – for example, you can describe the relationships between nodes by using their IDs.
Insertion and access by index is efficient, as it’s backed by a simple Vec
§Alternatives
There are plenty of crates implementing Arenas. The focus of this crate is simplicity – no bells or whistles.
If you want your IDs to stick around even after you remove their corresponding item without causing confusion, consider using generational-arena instead. With that crate, IDs also keep track of the slot’s “generation”. Removing an item, then adding a new item will produce an ID with a different generation, even though the slot might be the same. (Unlike this crate, where IDs will be reused).
Structs§
- Arena
- A collection of items with stable IDs
- Arena
Items - Iterator over all items in an
Arena
- EntryId
- The ID of an entry in an
Arena
Enums§
- Insert
Reserved Error - Error for
Arena::insert_reserved
– could not insert into the specified slot