HashMap implements Index, but not IndexMut, because it would likely conflict with future language features that don't exist yet and may never, but we still reserve the possibility because it would be nice for map[key] = value to autovivify key in map if it doesn't yet exist (instead of panicking, which is the best possible outcome with IndexMut).
The upshot is, HashMap is mutable, just use get_mut instead of indexing with []. (Since get_mut returns an Option, you will have to handle the None case explicitly.)
You should read the documentation. How could HashMapnot be mutable if there are multiple mutating methods on it, such as insert(), remove(), retain(), etc?
The automatic default-construction in C++'s std::unordered_map has a non-direct but functional and richer equivalent: the Entry API. What you likely want is: