MCPcopy Create free account
hub / github.com/hashintel/hash / get_or_insert_with

Method get_or_insert_with

libs/@local/hashql/core/src/id/vec.rs:561–563  ·  view source on GitHub ↗

Gets the value at `index`, or inserts one by calling `value` if it doesn't exist. This method works on `IdVec >` to provide map-like semantics. If the index is out of bounds or contains `None`, `value` is called to create a new element. # Examples ``` # use hashql_core::id::{IdVec, Id as _, newtype}; # newtype!(struct MyId(u32 is 0..=100)); let mut vec = IdVec::

(&mut self, index: I, value: impl FnOnce() -> T)

Source from the content-addressed store, hash-verified

559 /// assert_eq!(vec.len(), 3);
560 /// ```
561 pub fn get_or_insert_with(&mut self, index: I, value: impl FnOnce() -> T) -> &mut T {
562 self.fill_until(index, || None).get_or_insert_with(value)
563 }
564}
565
566impl<I, T, A> Debug for IdVec<I, T, A>

Callers 11

entity_editionsMethod · 0.45
entity_idsMethod · 0.45
entity_type_idsMethod · 0.45
left_entityMethod · 0.45
right_entityMethod · 0.45
determine_block_defMethod · 0.45
runMethod · 0.45
run_inMethod · 0.45
find_best_providerMethod · 0.45
time_indexMethod · 0.45

Calls 1

fill_untilMethod · 0.45

Tested by

no test coverage detected