Closed gzp79 closed 1 year ago
For the moment, no, this is the best option I can think of. You can wrap it in a function to make it more convenient though.
Keep in mind that if entry
returns None
that then either the key was invalid or outdated compared to what's in the SecondaryMap
. So ssm.entry(node_id).expect("outdated/invalid key").or_insert_with(Default::default)
might also do what you want.
Do you mean entry returns none only if the id is older than the current version in the map and for any other version that is not older than the one stored in the secondarymap an entry is returned ? If so than thank's this is just what I needed and the issue can be closed.
I have a SecondaryMap that is updated eventually: it may contain previous versions of an Id for a while and updated only on demand. I'm looking for an
get_or_insert
feature on the map and this is what I could put together with the current API:Is there any better, alternative option