rustc_data_structures/
fx.rs
1use std::hash::BuildHasherDefault;
2
3pub use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
4
5pub type StdEntry<'a, K, V> = std::collections::hash_map::Entry<'a, K, V>;
6
7pub type FxIndexMap<K, V> = indexmap::IndexMap<K, V, BuildHasherDefault<FxHasher>>;
8pub type FxIndexSet<V> = indexmap::IndexSet<V, BuildHasherDefault<FxHasher>>;
9pub type IndexEntry<'a, K, V> = indexmap::map::Entry<'a, K, V>;
10pub type IndexOccupiedEntry<'a, K, V> = indexmap::map::OccupiedEntry<'a, K, V>;
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}