Skip to content

Commit 6929f6d

Browse files
generic over hasher, to make clippy happy
1 parent 8e6275c commit 6929f6d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/poolable.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::collections::HashMap;
2-
use std::hash::Hash;
2+
use std::hash::{BuildHasher, Hash};
33

44
/// The trait required to be able to use a type in `BytePool`.
55
pub trait Poolable {
@@ -17,13 +17,17 @@ impl<T: Default + Clone> Poolable for Vec<T> {
1717
}
1818
}
1919

20-
impl<S: Eq + Hash, T> Poolable for HashMap<S, T> {
20+
impl<K, V, S> Poolable for HashMap<K, V, S>
21+
where
22+
K: Eq + Hash,
23+
S: BuildHasher + Default,
24+
{
2125
fn capacity(&self) -> usize {
2226
self.capacity()
2327
}
2428

2529
fn alloc(size: usize) -> Self {
26-
HashMap::with_capacity(size)
30+
HashMap::with_capacity_and_hasher(size, Default::default())
2731
}
2832
}
2933

@@ -48,7 +52,11 @@ impl<T: Default + Clone> Realloc for Vec<T> {
4852
}
4953
}
5054

51-
impl<S: Eq + Hash, T> Realloc for HashMap<S, T> {
55+
impl<K, V, S> Realloc for HashMap<K, V, S>
56+
where
57+
K: Eq + Hash,
58+
S: BuildHasher,
59+
{
5260
fn realloc(&mut self, new_size: usize) {
5361
use std::cmp::Ordering::*;
5462

0 commit comments

Comments
 (0)