#map

id-map

Data structure of values indexed by IDs

19 releases

Uses old Rust 2015

0.2.2 Aug 14, 2025
0.2.1 Sep 13, 2017
0.2.0 Jul 21, 2017
0.1.16 Jul 10, 2017
0.1.11 Jun 27, 2017

⚠️ Issues reported

#482 in Data structures

Download history 31/week @ 2025-08-17 5/week @ 2025-08-24 6/week @ 2025-09-28 3/week @ 2025-10-05

796 downloads per month

MIT license

25KB
678 lines

IdMap is a container that gives each item a unique id. Adding and removing by index is O(1).

Examples

#
let mut map = IdMap::new();
let blue_id = map.insert("blue");
let red_id = map.insert("red");

map.retain(|_, &color| color != "red");

assert!(!map.contains(red_id));
assert_eq!(map[blue_id], "blue");

id-map

See also slab or slotmap for a better optimized version of this crate.

Dependencies

~49KB