Impl IndexMut for HashMap

That is implementation defined. If you see my propsal above, we could always use index_assign when you have foo[index] = value, but give it the default impl to defer to index_mut to prevent a breaking change.

We can then change HashMap to update only on index_assign so that just accessing an element via index_mut doesn't change anything.

To me there isn't a dramatic difference between foo[i] = v and foo.insert(i, v), so I don't really miss it. I don't even use v = foo[i], because most of the time I don't know if they key is present, so I have to use .get() or .entry() anyway.

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.