fix: trait impl bugs (2)

This commit is contained in:
Shunsuke Shibayama 2024-12-27 01:14:19 +09:00
parent 017b13f07b
commit 40b53a3e81
4 changed files with 61 additions and 25 deletions

View file

@ -218,6 +218,11 @@ impl<K, V> Dict<K, V> {
self.dict.retain(f);
}
pub fn retained(mut self, f: impl FnMut(&K, &mut V) -> bool) -> Self {
self.retain(f);
self
}
pub fn get_by(&self, k: &K, cmp: impl Fn(&K, &K) -> bool) -> Option<&V> {
for (k_, v) in self.dict.iter() {
if cmp(k, k_) {