indexmap-rs/indexmap

Signature of OccupiedEntry::insert

Closed this issue · 2 comments

The first three all take &mut self while indexmap takes self by value. Is this intentional? I found this makes it complicated for a library to multiplex across different choices of underlying map type: serde-rs/json#418.

My workaround is:

mem::replace(occupied_entry.get_mut(), value)

Seems like something we should fix. Most of the API tries to be consistent with HashMap, and I don't see a reason why this would need an exception.

bluss commented

@dtolnay thanks a lot for catching this before our 1.0