(&self, k: K, modify: M, insert: I)
| 570 | } |
| 571 | |
| 572 | pub fn modify_or_insert<M, I>(&self, k: K, modify: M, insert: I) |
| 573 | where |
| 574 | M: FnOnce(&mut V), |
| 575 | I: FnOnce() -> V, |
| 576 | { |
| 577 | let index = self.hash_key(&k); |
| 578 | let mut ht = self.hash_table_list[index].lock().unwrap(); |
| 579 | ht.entry(k).and_modify(modify).or_insert_with(insert); |
| 580 | } |
| 581 | |
| 582 | // works exactly like `modify_or_insert`, but takes a value `T`, which is passed to both |
| 583 | // closures (only one actually runs, so only passed to one of them), which is not possible |