The current Index isn't great because you have to use &self and return &T or T (via clone) for a map/vector type.
I think it would be best to split it into Index (with &self), IndexMut (with &mut self) and IndexAssign (&mut self, inserting a value).
I'm unsure about the syntax. It would be nice to make it uniform with vector syntax and have &a["foo"] call Index for &T, etc.
The current
Indexisn't great because you have to use&selfand return&TorT(via clone) for a map/vector type.I think it would be best to split it into
Index(with&self),IndexMut(with&mut self) andIndexAssign(&mut self, inserting a value).I'm unsure about the syntax. It would be nice to make it uniform with vector syntax and have
&a["foo"]callIndexfor&T, etc.