rustc-hash provides FxHashMap and FxHashSet as high-performance alternatives to the standard library's HashMap and HashSet. These collections use the FxHasher, a non-cryptographic hashing algorithm designed for speed.
While std::collections::HashMap uses SipHash to protect against DOS attacks, FxHashMap prioritizes raw performance, making it ideal for scenarios where cryptographic security is not required (such as in compilers or internal data processing). FxHashMap and FxHashSet are type aliases for their std counterparts configured with the FxHasher.
Note: The underlying algorithm is a polynomial hash with a single bit rotation and a wyhash-inspired compression function for strings/slices.
use rustc_hash::FxHashMap;
let mut map: FxHashMap<u32, u32> = FxHashMap::default();
map.insert(22, 44);