Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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)].
  • Loading branch information
antrik committed Dec 12, 2015
1 parent 23b2206 commit 3d078f7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/util/cache.rs
Expand Up @@ -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>>,
}

Expand Down

0 comments on commit 3d078f7

Please sign in to comment.