jsonld_syntax/hash.rs
1//! Workspace-wide hasher selection.
2//!
3//! Default: hashbrown's [`hashbrown::DefaultHashBuilder`] (`FoldHash` on
4//! hashbrown 0.15+). The `ahash` and `gxhash` features each swap in a
5//! different hasher.
6//!
7//! Cargo unifies features across a dependency graph, so two unrelated
8//! dependants asking for different hashers must not break the build: when
9//! both features end up enabled, `gxhash` wins.
10
11/// Hasher used by the collections of this crate.
12#[cfg(feature = "gxhash")]
13pub type DefaultBuildHasher = gxhash::GxBuildHasher;
14
15/// Hasher used by the collections of this crate.
16#[cfg(all(feature = "ahash", not(feature = "gxhash")))]
17pub type DefaultBuildHasher = ahash::RandomState;
18
19/// Hasher used by the collections of this crate.
20#[cfg(not(any(feature = "ahash", feature = "gxhash")))]
21pub type DefaultBuildHasher = hashbrown::DefaultHashBuilder;
22
23/// Hash map using [`DefaultBuildHasher`].
24pub type HashMap<K, V, S = DefaultBuildHasher> = hashbrown::HashMap<K, V, S>;
25
26/// Hash set using [`DefaultBuildHasher`].
27pub type HashSet<T, S = DefaultBuildHasher> = hashbrown::HashSet<T, S>;
28
29/// Insertion-ordered map using [`DefaultBuildHasher`].
30pub type IndexMap<K, V, S = DefaultBuildHasher> = indexmap::IndexMap<K, V, S>;
31
32/// Insertion-ordered set using [`DefaultBuildHasher`].
33pub type IndexSet<T, S = DefaultBuildHasher> = indexmap::IndexSet<T, S>;