$ slotmap

v1.1.1

Slotmap data structure

Downloads: 44.4M
Recent: 8.6M
Versions: 21
Updated: December 6, 2025

Latest Update Summary

Crate

Name: slotmap New version: 1.1.0 Release date: 2025-12-06T00:16:03.307517Z

Crate readme

Short description A Rust library providing three containers with persistent unique keys to access stored values.

Long description The crate offers SlotMap, HopSlotMap, and DenseSlotMap, allowing O(1) insertion, deletion, and access times. It is suitable for collections with stable references, like game entities or graph nodes. It also includes SecondaryMap and SparseSecondaryMap for additional mappings. The minimum required stable Rust version is 1.58.

Features • O(1) insertion, deletion, and access times • Supports unique keys for safe references • Includes SecondaryMap and SparseSecondaryMap • Minimum stable Rust version: 1.58

Code Examples Add to Cargo.toml

 [dependencies]
slotmap = "1.0"

Basic usage

 use slotmap::{SlotMap, SecondaryMap};

let mut sm = SlotMap::new();
let foo = sm.insert("foo");  // Key generated on insert.
let bar = sm.insert("bar");
assert_eq!(sm[foo], "foo");
assert_eq!(sm[bar], "bar");

sm.remove(bar);
let reuse = sm.insert("reuse");  // Space from bar reused.
assert_eq!(sm.contains_key(bar), false);  // After deletion a key stays invalid.

let mut sec = SecondaryMap::new();
sec.insert(foo, "noun");  // We provide the key for secondary maps.
sec.insert(reuse, "verb");

for (key, val) in sm {
    println!("{} is a {}", val, sec[key]);
}

Linkshttps://docs.rs/slotmap

Release info

Release version: N/A

Release description N/A

Code Examples N/A

Patch update: 1.1.0 → 1.1.1

$ DOWNLOADS TREND

38.6M44.4M

$ VERSION HISTORY

v1.1.1December 6, 2025
v1.1.0December 6, 2025
v1.0.7November 30, 2023

$ LINKS

$ INSTALL

cargo add slotmap

Or add to Cargo.toml: slotmap = "1.1.1"