HashCache: Apply trait bounds on type itself, rather than only the impl

I don't think there is any reason to keep the container more generic
than its (only) implementation -- the constraints are necessary for this
container to work at all.

Defining the constraints on the type itself also enables use
of #[derive(Debug)].
This commit is contained in:
Olaf Buddenhagen 2015-12-09 19:29:11 +01:00
parent 23b220644c
commit 3d078f7c64

View file

@ -12,7 +12,10 @@ use std::hash::{Hash, Hasher, SipHasher};
use std::slice::Iter;
pub struct HashCache<K, V> {
pub struct HashCache<K, V>
where K: Clone + PartialEq + Eq + Hash,
V: Clone,
{
entries: HashMap<K, V, DefaultState<SipHasher>>,
}