use super::fast::{FixedState, RandomState}; /// Type alias for [`std::collections::HashMap`]. pub type HashMap = std::collections::HashMap; /// Type alias for [`std::collections::HashSet`]. pub type HashSet = std::collections::HashSet; /// A convenience extension trait to enable [`HashMap::new`] for hash maps that use `foldhash`. pub trait HashMapExt { /// Creates an empty `HashMap`. fn new() -> Self; /// Creates an empty `HashMap` with at least the specified capacity. fn with_capacity(capacity: usize) -> Self; } impl HashMapExt for std::collections::HashMap { fn new() -> Self { Self::with_hasher(RandomState::default()) } fn with_capacity(capacity: usize) -> Self { Self::with_capacity_and_hasher(capacity, RandomState::default()) } } impl HashMapExt for std::collections::HashMap { fn new() -> Self { Self::with_hasher(FixedState::default()) } fn with_capacity(capacity: usize) -> Self { Self::with_capacity_and_hasher(capacity, FixedState::default()) } } /// A convenience extension trait to enable [`HashSet::new`] for hash sets that use `foldhash`. pub trait HashSetExt { /// Creates an empty `HashSet`. fn new() -> Self; /// Creates an empty `HashSet` with at least the specified capacity. fn with_capacity(capacity: usize) -> Self; } impl HashSetExt for std::collections::HashSet { fn new() -> Self { Self::with_hasher(RandomState::default()) } fn with_capacity(capacity: usize) -> Self { Self::with_capacity_and_hasher(capacity, RandomState::default()) } } impl HashSetExt for std::collections::HashSet { fn new() -> Self { Self::with_hasher(FixedState::default()) } fn with_capacity(capacity: usize) -> Self { Self::with_capacity_and_hasher(capacity, FixedState::default()) } }