Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Adds S to HashMap/HashSet impls of Contains (#33973)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Nov 8, 2023
1 parent 06884a0 commit 7cb83bc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions accounts-db/src/contains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{
borrow::Borrow,
cmp::Eq,
collections::{HashMap, HashSet},
hash::Hash,
hash::{BuildHasher, Hash},
};

pub trait Contains<'a, T: Eq + Hash> {
Expand All @@ -12,24 +12,24 @@ pub trait Contains<'a, T: Eq + Hash> {
fn contains_iter(&'a self) -> Self::Iter;
}

impl<'a, T: 'a + Eq + Hash, U: 'a> Contains<'a, T> for HashMap<T, U> {
impl<'a, T: 'a + Eq + Hash, U: 'a, S: BuildHasher> Contains<'a, T> for HashMap<T, U, S> {
type Item = &'a T;
type Iter = std::collections::hash_map::Keys<'a, T, U>;

fn contains(&self, key: &T) -> bool {
<HashMap<T, U>>::contains_key(self, key)
<HashMap<T, U, S>>::contains_key(self, key)
}
fn contains_iter(&'a self) -> Self::Iter {
self.keys()
}
}

impl<'a, T: 'a + Eq + Hash> Contains<'a, T> for HashSet<T> {
impl<'a, T: 'a + Eq + Hash, S: BuildHasher> Contains<'a, T> for HashSet<T, S> {
type Item = &'a T;
type Iter = std::collections::hash_set::Iter<'a, T>;

fn contains(&self, key: &T) -> bool {
<HashSet<T>>::contains(self, key)
<HashSet<T, S>>::contains(self, key)
}
fn contains_iter(&'a self) -> Self::Iter {
self.iter()
Expand Down

0 comments on commit 7cb83bc

Please sign in to comment.