Entry API add default and modify it

The following snippet returns the default value, if the key is not present:

some_map.entry(key)
   .and_modify(modifier_fn)
   .or_default();

I want modifier_fn to be applied to the default value. I can achieve it like this:

some_map.entry(key)
   .or_default();
some_map.entry(key)
   .and_modify(modifier_fn);

but is there a more concise way, that calls some_map.entry(key) only once?

modifier_fn(some_map.entry(key).or_default());

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.