Closed M5135213521asd3 closed 1 month ago
There's no method for it, as there are many variations of behavior that might be desired. The most generic way is to use Extend
, like map.extend(other)
, or map.extend(other.drain(..))
to keep the other allocation.
This is equivalent to calling
insert
for each of them in order, which means that for keys that already existed in the map, their value is updated but it keeps the existing order.
If you want different update semantics, you can iterate the other map yourself and use the entry
API for efficient lookups to update the target map.
It's also up to you to decide the desired order of the resulting map, and make that happen.
The standard library also has BTreeMap::append
, BTreeSet::append
, and Vec::append
, but not for HashMap
and HashSet
. I think it would be fine to add to IndexMap::append
and IndexSet::append
though, with the same insert
-replacement semantics that I mentioned before.
Hi, could it be possible to implement join two IndexMap to one, or insert one IndexMap to another?
Thank you, Marian