rustc_data_structures/
fx.rs1pub use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet, FxHasher};
2
3pub type StdEntry<'a, K, V> = std::collections::hash_map::Entry<'a, K, V>;
4
5pub type FxIndexMap<K, V> = indexmap::IndexMap<K, V, FxBuildHasher>;
6pub type FxIndexSet<V> = indexmap::IndexSet<V, FxBuildHasher>;
7pub type IndexEntry<'a, K, V> = indexmap::map::Entry<'a, K, V>;
8pub type IndexOccupiedEntry<'a, K, V> = indexmap::map::OccupiedEntry<'a, K, V>;
9
10pub use indexmap::set::MutableValues;
11
12#[macro_export]
13macro_rules! define_id_collections {
14 ($map_name:ident, $set_name:ident, $entry_name:ident, $key:ty) => {
15 pub type $map_name<T> = $crate::unord::UnordMap<$key, T>;
16 pub type $set_name = $crate::unord::UnordSet<$key>;
17 pub type $entry_name<'a, T> = $crate::fx::StdEntry<'a, $key, T>;
18 };
19}
20
21#[macro_export]
22macro_rules! define_stable_id_collections {
23 ($map_name:ident, $set_name:ident, $entry_name:ident, $key:ty) => {
24 pub type $map_name<T> = $crate::fx::FxIndexMap<$key, T>;
25 pub type $set_name = $crate::fx::FxIndexSet<$key>;
26 pub type $entry_name<'a, T> = $crate::fx::IndexEntry<'a, $key, T>;
27 };
28}
29
30pub mod default {
31 use super::{FxBuildHasher, FxHashMap, FxHashSet};
32
33 pub const fn fx_hash_map<K, V>() -> FxHashMap<K, V> {
37 FxHashMap::with_hasher(FxBuildHasher)
38 }
39
40 pub const fn fx_hash_set<V>() -> FxHashSet<V> {
41 FxHashSet::with_hasher(FxBuildHasher)
42 }
43}