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


#1

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?


#2

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.


#3

Thanks a lot, I was definitely missing something !