Skip to content

Commit 6d3ed21

Browse files
committed
better get
1 parent 49073d6 commit 6d3ed21

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/src/utils/concurrent_hashmap.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::borrow::Borrow;
12
use std::collections::hash_map::Entry;
23
use std::collections::HashMap;
34
use std::hash::Hash;
@@ -30,7 +31,11 @@ where
3031
map.insert(key, value)
3132
}
3233

33-
pub fn get(&self, key: &K) -> Option<V> {
34+
pub fn get<Q>(&self, key: &Q) -> Option<V>
35+
where
36+
K: Borrow<Q>,
37+
Q: Hash + Eq + ?Sized,
38+
{
3439
let map = self.inner.read().unwrap();
3540
map.get(key).cloned()
3641
}

0 commit comments

Comments
 (0)