Skip to main content

insert_into_next_slot

Function insert_into_next_slot 

Source
pub(crate) async fn insert_into_next_slot<F, K, U, V>(
    cache: &Cache<K, V>,
    generator: F,
    value_fn: U,
) -> Option<(K, V)>
where F: FnMut(Option<K>) -> K, K: Copy + Hash + Eq + Send + Sync + 'static, U: FnOnce(K) -> V, V: Clone + Send + Sync + 'static,
Expand description

This function will use the given generator to generate an initial seeding key. It will check whether the given cache already contains a value for that key, and if not, calls the generator (with the previous value) to generate a new seeding key and retry. The function either finds a suitable free slot, inserting value generated by value_fn and returns the found key, or terminates with None when gen returns the initial seed again.