indexmap-rs / indexmap

A hash table with consistent order and fast iteration; access items by key or sequence index

Home Page:https://docs.rs/indexmap/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: try_insert method

mb64 opened this issue · comments

The standard library hashmap and btree map recently got a nightly-only try_insert operation (here's the tracking issue), which makes it very convenient to insert something into a map, panicking in the case that it's already there:

the_map.try_insert(key, value).unwrap();

It would be nice to also have this for IndexMap.

We're happy to match such methods once they're stable, but until then it's subject to change, and we don't want indexmap to get stuck with differences.