Module map

Expand description

Re-exports of map types and utilities.

This module exports the following types:

  • HashMap and HashSet from the standard library or hashbrown crate. The “map-hashbrown” feature can be used to force the use of hashbrown, and is required in no_std environments.
  • IndexMap and IndexSet from the indexmap crate, if the “map-indexmap” feature is enabled.
  • The previously-listed hash map types prefixed with Fb. These are type aliases with FixedBytes<N> as the key, and FbBuildHasher as the hasher builder. This hasher is optimized for hashing fixed-size byte arrays, and wraps around the default hasher builder. It performs best when the hasher is fxhash, which is enabled by default with the “map-fxhash” feature.
  • The previously-listed hash map types prefixed with Selector, Address, and B256. These use FbBuildHasher with the respective fixed-size byte array as the key. See the previous point for more information.

Unless specified otherwise, the default hasher builder used by these types is DefaultHashBuilder. This hasher prioritizes speed over security. Users who require HashDoS resistance should enable the “rand” feature so that the hasher is initialized using a random seed.

Note that using the types provided in this module may require using different APIs than the standard library as they might not be generic over the hasher state, such as using HashMap::default() instead of HashMap::new().

Modules§

foldhash
This crate provides foldhash, a fast, non-cryptographic, minimally DoS-resistant hashing algorithm designed for computational uses such as hashmaps, bloom filters, count sketching, etc.
hash_map
A hash map implemented with quadratic probing and SIMD lookup.
hash_set
A hash set implemented as a HashMap where the value is ().
indexmap
IndexMap is a hash table where the iteration order of the key-value pairs is independent of the hash values of the keys.
rustc_hash
A speedy, non-cryptographic hashing algorithm used by rustc.

Structs§

FbBuildHasher
BuildHasher optimized for hashing fixed-size byte arrays.
FbHasher
Hasher optimized for hashing fixed-size byte arrays.
FxHasher
A speedy hash algorithm for use within rustc. The hashmap in liballoc by default uses SipHash which isn’t quite as speedy as we want. In the compiler we’re not really worried about DOS attempts, so we use a fast non-cryptographic hash.

Enums§

Entry
A view into a single entry in a map, which may either be vacant or occupied.
IndexEntry
Entry for an existing key-value pair in an IndexMap or a vacant location to insert one.

Type Aliases§

AddressIndexMap
IndexMap optimized for hashing Address.
AddressIndexSet
IndexSet optimized for hashing Address.
AddressMap
HashMap optimized for hashing Address.
AddressSet
HashSet optimized for hashing Address.
B256IndexMap
IndexMap optimized for hashing B256.
B256IndexSet
IndexSet optimized for hashing B256.
B256Map
HashMap optimized for hashing B256.
B256Set
HashSet optimized for hashing B256.
DefaultHashBuilder
The default BuildHasher used by HashMap and HashSet.
DefaultHasher
The default Hasher used by HashMap and HashSet.
FbIndexMap
IndexMap optimized for hashing fixed-size byte arrays.
FbIndexSet
IndexSet optimized for hashing fixed-size byte arrays.
FbMap
HashMap optimized for hashing fixed-size byte arrays.
FbSet
HashSet optimized for hashing fixed-size byte arrays.
FxBuildHasher
The FxHasher hasher builder.
HashMap
A HashMap using the default hasher.
HashSet
A HashSet using the default hasher.
IndexMap
IndexMap using the default hasher.
IndexSet
IndexSet using the default hasher.
SelectorIndexMap
IndexMap optimized for hashing Selector.
SelectorIndexSet
IndexSet optimized for hashing Selector.
SelectorMap
HashMap optimized for hashing Selector.
SelectorSet
HashSet optimized for hashing Selector.