Skip to content

Commit

Permalink
add PartialEq, Eq impl for pub types
Browse files Browse the repository at this point in the history
  • Loading branch information
troublescooter committed Jun 29, 2020
1 parent c30d033 commit 519c517
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/stores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ pub struct UnboundCache<K, V> {
initial_capacity: Option<usize>,
}

impl<K, V> PartialEq for UnboundCache<K, V>
where
K: Eq + Hash,
V: PartialEq,
{
fn eq(&self, other: &UnboundCache<K, V>) -> bool {
self.store.eq(&other.store)
}
}

impl<K, V> Eq for UnboundCache<K, V>
where
K: Eq + Hash,
V: PartialEq,
{
}

impl<K: Hash + Eq, V> UnboundCache<K, V> {
/// Creates an empty `UnboundCache`
#[allow(clippy::new_without_default)]
Expand Down Expand Up @@ -254,6 +271,23 @@ pub struct SizedCache<K, V> {
misses: u64,
}

impl<K, V> PartialEq for SizedCache<K, V>
where
K: Eq + Hash,
V: PartialEq,
{
fn eq(&self, other: &SizedCache<K, V>) -> bool {
self.store.eq(&other.store)
}
}

impl<K, V> Eq for SizedCache<K, V>
where
K: Eq + Hash,
V: PartialEq,
{
}

impl<K: Hash + Eq, V> SizedCache<K, V> {
#[deprecated(since = "0.5.1", note = "method renamed to `with_size`")]
pub fn with_capacity(size: usize) -> SizedCache<K, V> {
Expand Down

0 comments on commit 519c517

Please sign in to comment.