MCPcopy Create free account
hub / github.com/cosdata/cosdata / modify_or_insert

Method modify_or_insert

src/models/common.rs:572–580  ·  view source on GitHub ↗
(&self, k: K, modify: M, insert: I)

Source from the content-addressed store, hash-verified

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

Callers 4

insertMethod · 0.80
insertMethod · 0.80
insertMethod · 0.80

Calls 1

hash_keyMethod · 0.80

Tested by 1