SwissTable-based HashMap and HashSet for Rust, the implementation behind the standard library's
open sourceApache-2.0 OR MITfree
hashbrown provides the implementation of Rust's standard library HashMap and HashSet, outside the standard library's stability guarantees. It began as a Rust port of Google's SwissTable hash map and is a drop-in replacement for the standard types: about twice as fast as the old standard HashMap, 1 byte of overhead per entry, SIMD lookups, no allocation for empty maps, and no_std support with a global allocator. It's a Rust Project crate.
Problems it solves
- a faster hash map for Rust than the standard one
- use HashMap and HashSet in a no_std Rust crate
- a Rust hash map with lower memory overhead per entry
Features
- Drop-in replacement for the standard HashMap and HashSet
- foldhash as the default hasher
- 1 byte of overhead per entry and no allocation for empty maps
- SIMD lookups across several entries at once
- no_std support (with a global allocator), plus optional serde and rayon support
Limitations
- Its default hasher, foldhash, doesn't resist HashDoS as well as SipHash; use another hasher when that matters.1
Alternatives
The same job
These do what hashbrown does.
- rustc-hash The fast, non-cryptographic FxHasher that rustc uses, with FxHashMap and FxHashSet
- Rust-PHF Compile-time perfect-hash lookup tables for Rust
- indexmap Rust hash map and set that keep insertion order and index entries
