Why has Index trait has an associated type Output and not IndexMut?


Here: https://doc.rust-lang.org/std/ops/trait.IndexMut.html

and here: https://doc.rust-lang.org/std/ops/trait.Index.html

Am I missing something?


Notice that it’s dependent, IndexMut: Index, so it reuses the same Output type. So here:

    fn index_mut(&mut self, index: Idx) -> &mut Self::Output;

It really means -> &mut <Self as Index>::Output.


Thanks a lot, I was definitely missing something !