autocommit 2022-04-01 01:44:10 CEST
This commit is contained in:
parent
ab4ac883ee
commit
2dd433aa04
32 changed files with 626 additions and 139 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use ahash::AHashMap;
|
||||
use std::borrow::Borrow;
|
||||
use std::cell::{RefCell, RefMut};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::hash::Hash;
|
||||
|
|
@ -31,9 +32,11 @@ impl<K: Eq + Hash, V> CopyHashMap<K, V> {
|
|||
self.map.borrow_mut().insert(k, v);
|
||||
}
|
||||
|
||||
pub fn get(&self, k: &K) -> Option<V>
|
||||
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<V>
|
||||
where
|
||||
V: Clone,
|
||||
Q: Hash + Eq,
|
||||
K: Borrow<Q>,
|
||||
{
|
||||
self.map.borrow_mut().get(k).cloned()
|
||||
}
|
||||
|
|
@ -42,7 +45,11 @@ impl<K: Eq + Hash, V> CopyHashMap<K, V> {
|
|||
self.map.borrow_mut().remove(k)
|
||||
}
|
||||
|
||||
pub fn contains(&self, k: &K) -> bool {
|
||||
pub fn contains<Q: ?Sized>(&self, k: &Q) -> bool
|
||||
where
|
||||
Q: Hash + Eq,
|
||||
K: Borrow<Q>,
|
||||
{
|
||||
self.map.borrow_mut().contains_key(k)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue