Async or_insert_with

What I would like to do:

hash_map.entry(1).or_insert_with(|| { something().await; return 2; })

What I believe I have to do:

match hash_map.entry(1) {
    Entry::Occupied(_) => {...}, 
    Entry::Vacant(entry) => {
        something.await;
        entry.insert(2);
    }
}

Am I right or am I missing something?

You aren't missing anything. There isn't an async version of that method.

1 Like