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

Adds S to HashMap/HashSet impls of Contains #33973

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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