idcontain
A Rust library for containers built around 'generational id-s': tagged id-s which prevent errors caused by id reuse, id mixing (between different containers) and enable 'dangling id' detection (using an id after it was deleted).
Currently the only implemented type is IdSlab
which is an unordered collection,
sometimes called a Slab
allocator. It differs from @carllerche's excellent
Slab in its support for the properties
described above at a small cost in memory and speed.
The particular implementation used for preventing ID reuse and mixing has some caveats (i.e. pathological cases causing false positives in membership tests) which mean you should not rely on it for memory safety or security. These cases are quite extreme so you're definitely OK to use this for video games etc. See the documentation for more details.
An old but relevant blog post about this technique.
Getting Started
Add the dependency to your Cargo.toml
manifest.
[]
= "0.6"
Example
extern crate idcontain;
use ;
Iteration and other stuff is also supported, check out the documentation!