]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #21949 - japaric:index, r=nikomatsakis
authorbors <bors@rust-lang.org>
Sat, 7 Feb 2015 04:14:22 +0000 (04:14 +0000)
committerbors <bors@rust-lang.org>
Sat, 7 Feb 2015 04:14:22 +0000 (04:14 +0000)
closes #21630

Overloaded indexing (`&[mut] foo[bar]`) only works when `<Self as Index>::Output` is the same as `<Self as IndexMut>::Output` (see issue above). To restrict implementations of `IndexMut` that doesn't work, this PR makes `IndexMut` a supertrait over `Index`, i.e. `trait IndexMut<I>: Index<I>`, just like in the `trait DerefMut: Deref` case.

This breaks all downstream implementations of `IndexMut`, in most cases this simply means removing the `type Output = ..` bit, which is now redundant, from `IndexMut` implementations:

``` diff
 impl Index<Foo> for Bar {
     type Output = Baz;
     ..
 }

 impl IndexMut<Foo> for Bar {
-    type Output = Baz;
     ..
 }
```

[breaking-change]

---

r? @nikomatsakis


Trivial merge