External Publication
Visit Post

`alloc`-only `HashMap`?

Rust Internals [Unofficial] April 6, 2026
Source

A few alternatives:

Have you considered using the hashbrown crate? It is the crate std uses for its hashmap/hashset implementation. This crate is no_std compatible.

If you don't want to add a new dependency, then you could use BTreeMap and BTreeSet, which do live in the alloc crate.

If you do need HashMap specifically, then you are a bit out of luck.

Discussion in the ATmosphere

Loading comments...