-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Expand file tree
/
Copy pathfx.rs
More file actions
46 lines (37 loc) · 1.73 KB
/
Copy pathfx.rs
File metadata and controls
46 lines (37 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use std::alloc::Global;
pub use rustc_hash::{FxBuildHasher, FxHashSet, FxHasher};
pub type StdEntry<'a, K, V> = std::collections::hash_map::Entry<'a, K, V>;
pub type FxHashMap<K, V, A = Global> = std::collections::HashMap<K, V, FxBuildHasher, A>;
pub type FxIndexMap<K, V> = indexmap::IndexMap<K, V, FxBuildHasher>;
pub type FxIndexSet<V> = indexmap::IndexSet<V, FxBuildHasher>;
pub type IndexEntry<'a, K, V> = indexmap::map::Entry<'a, K, V>;
pub type IndexOccupiedEntry<'a, K, V> = indexmap::map::OccupiedEntry<'a, K, V>;
pub use indexmap::set::MutableValues;
#[macro_export]
macro_rules! define_id_collections {
($map_name:ident, $set_name:ident, $entry_name:ident, $key:ty) => {
pub type $map_name<T> = $crate::unord::UnordMap<$key, T>;
pub type $set_name = $crate::unord::UnordSet<$key>;
pub type $entry_name<'a, T> = $crate::fx::StdEntry<'a, $key, T>;
};
}
#[macro_export]
macro_rules! define_stable_id_collections {
($map_name:ident, $set_name:ident, $entry_name:ident, $key:ty) => {
pub type $map_name<T> = $crate::fx::FxIndexMap<$key, T>;
pub type $set_name = $crate::fx::FxIndexSet<$key>;
pub type $entry_name<'a, T> = $crate::fx::IndexEntry<'a, $key, T>;
};
}
pub mod default {
use super::{FxBuildHasher, FxHashMap, FxHashSet};
// FIXME: These two functions will become unnecessary after
// <https://github.com/rust-lang/rustc-hash/pull/63> lands and we start using the corresponding
// `rustc-hash` version. After that we can use `Default::default()` instead.
pub const fn fx_hash_map<K, V>() -> FxHashMap<K, V> {
FxHashMap::with_hasher(FxBuildHasher)
}
pub const fn fx_hash_set<V>() -> FxHashSet<V> {
FxHashSet::with_hasher(FxBuildHasher)
}
}