foldhash/
convenience.rs
1use super::fast::{FixedState, RandomState};
2
3pub type HashMap<K, V> = std::collections::HashMap<K, V, RandomState>;
5
6pub type HashSet<T> = std::collections::HashSet<T, RandomState>;
8
9pub trait HashMapExt {
11 fn new() -> Self;
13
14 fn with_capacity(capacity: usize) -> Self;
16}
17
18impl<K, V> HashMapExt for std::collections::HashMap<K, V, RandomState> {
19 fn new() -> Self {
20 Self::with_hasher(RandomState::default())
21 }
22
23 fn with_capacity(capacity: usize) -> Self {
24 Self::with_capacity_and_hasher(capacity, RandomState::default())
25 }
26}
27
28impl<K, V> HashMapExt for std::collections::HashMap<K, V, FixedState> {
29 fn new() -> Self {
30 Self::with_hasher(FixedState::default())
31 }
32
33 fn with_capacity(capacity: usize) -> Self {
34 Self::with_capacity_and_hasher(capacity, FixedState::default())
35 }
36}
37
38pub trait HashSetExt {
40 fn new() -> Self;
42
43 fn with_capacity(capacity: usize) -> Self;
45}
46
47impl<T> HashSetExt for std::collections::HashSet<T, RandomState> {
48 fn new() -> Self {
49 Self::with_hasher(RandomState::default())
50 }
51
52 fn with_capacity(capacity: usize) -> Self {
53 Self::with_capacity_and_hasher(capacity, RandomState::default())
54 }
55}
56
57impl<T> HashSetExt for std::collections::HashSet<T, FixedState> {
58 fn new() -> Self {
59 Self::with_hasher(FixedState::default())
60 }
61
62 fn with_capacity(capacity: usize) -> Self {
63 Self::with_capacity_and_hasher(capacity, FixedState::default())
64 }
65}