How to remove with HashMap's Entry API?

HashMap's top-level documentation says (emphasis mine):

HashMap also implements an Entry API , which allows for more complex methods of getting, setting, updating and removing keys and their values:

But I've been staring at the documentation for Entry and don't see any sign of how to do a remove. Any insights?

It looks like you need to match on the Entry and then in the Occupied arm you can use e.g. OccupiedEntry::remove_entry.


Thanks! I didn't think to look there, though obvious in hindsight.

You're welcome! It does seem odd that there isn't a similar method, something like Option::take, on Entry itself.

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.