DashMap implements a thread-safe associative map in Rust with a HashMap-like API that uses shared references instead of exclusive mutable access.
Overview
DashMap is a Rust crate that provides a concurrent associative array or hash map intended as a drop-in style alternative to wrapping std::collections::HashMap in synchronization primitives.
Methods take shared references on the map itself, so you can place the structure inside an Arc and modify it from multiple threads without requiring a single writer lock for every operation. The API deliberately mirrors std HashMap with adjustments for concurrency.
Optional Cargo features add serde serialization, an unstable raw shard API, rayon integration, extra inlining via hashbrown, and arbitrary testing support. The maintainers point to an external benchmark suite for performance comparisons.
You add DashMap as a normal Rust dependency; it runs wherever your compiled Rust program runs. It is a library component, not a standalone end-user application.
Key features
- Concurrent reads and writes
- HashMap-like shared-ref API
- Arc-friendly cross-thread use
- Optional serde support
- Optional rayon integration
- hashbrown inline-more feature flag
- Documented MSRV policy
Use cases
- Shared in-memory caches across threads
- Concurrent lookup tables in servers
- Replacing RwLock-wrapped HashMaps
- Parallel Rust data structures
- Serde-serializable concurrent maps