hashbrown
A Rust port of Google's SwissTable hash map
This package has a good security score with no known vulnerabilities.
Community Reviews
Drop-in replacement for std HashMap with minimal learning curve
The documentation is solid with clear examples for standard usage. Error messages are what you'd expect from Rust - the compiler guides you well since the traits and patterns match std conventions. When I've had questions, the crate docs plus existing Rust HashMap knowledge got me 95% of the way. The `raw` API documentation could be more detailed for advanced use cases, but standard HashMap operations are trivial.
Debugging is straightforward since the mental model is identical to std HashMap. When things go wrong, it's usually about your key/value types, not the map itself. The main gotcha is understanding when you need hashbrown over std (spoiler: usually you don't unless you need the extra features or no_std support).
Best for: Projects needing no_std HashMap support, custom allocators, or the raw entry API for performance optimization.
Avoid if: You're using std and don't need special features - just use std::collections::HashMap which uses hashbrown internally anyway.
Rock-solid foundation HashMap with excellent security defaults
The API is nearly identical to std::collections::HashMap with some extras like `insert_unique_unchecked` for performance-critical validated paths and raw entry APIs for advanced control. Memory safety is guaranteed by Rust's type system, and the library never panics on invalid input - all operations return Results or Options appropriately. Error handling is predictable and never leaks sensitive information.
Dependency-wise, it's minimal with only ahash and allocator-api2 as defaults, both well-audited crates. The TLS/crypto story is handled upstream by the hasher (ahash by default), which uses hardware AES instructions when available for DoS protection. It follows secure-by-default principles religiously: you get randomized hashing out of the box without opt-in.
Best for: Any project needing a HashMap with maximum performance, or requiring features beyond std HashMap like raw entry API or custom allocators.
Avoid if: You need deterministic hashing across processes or machines (use IndexMap or BTreeMap instead).
Drop-in replacement for std HashMap with minimal learning curve
The documentation is minimal but sufficient because it largely defers to std HashMap docs. Error messages are standard Rust quality since the types integrate seamlessly with the compiler. When things go wrong, it's usually not hashbrown's fault but rather lifetime or borrowing issues you'd hit with any HashMap. Debugging is straightforward with standard tools.
The learning curve is essentially zero for basic usage. Advanced features like RawTable or raw entry API require more careful reading, but the docs provide enough context. Community support is indirect - most HashMap questions on Stack Overflow apply directly since the APIs match.
Best for: Projects needing a faster HashMap or requiring advanced features like raw entries while maintaining std API compatibility.
Avoid if: You only need basic HashMap functionality and don't want an extra dependency (std HashMap already uses it internally).
Sign in to write a review
Sign In