| Crates.io | sparse_map |
| lib.rs | sparse_map |
| version | 0.1.2 |
| created_at | 2026-01-06 14:03:02.497458+00 |
| updated_at | 2026-01-12 03:45:20.673291+00 |
| description | A sparse map with stable generational keys. |
| homepage | |
| repository | https://github.com/voxell-tech/sparse_map |
| max_upload_size | |
| id | 2025919 |
| size | 27,743 |
A sparse map with stable generational keys. It is designed for scenarios with frequent insertions and removals.
The crate is no_std-friendly and uses generational indices to
prevent use-after-free and slot reuse bugs.
use sparse_map::SparseMap;
let mut map = SparseMap::new();
let k1 = map.insert(42);
let k2 = map.scope(&k1, |map, value| {
let k = map.insert(*value);
*value += 2;
k
})
.expect("Key should exist.");
assert_eq!(map.get(&k1), Some(&44));
assert_eq!(map.get(&k2), Some(&42));
map.remove(&k1);
assert_eq!(map.get(&k1), None);
You can join us on the Voxell discord server.
sparse_map is dual-licensed under either:
This means you can select the license you prefer! This dual-licensing approach is the de-facto standard in the Rust ecosystem and there are very good reasons to include both.