diff options
| author | bors <bors@rust-lang.org> | 2015-02-07 04:14:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-02-07 04:14:22 +0000 |
| commit | 0b6dbbc9cfb747df1db646bba16561c022704056 (patch) | |
| tree | 1b6bf9780361f2cd8bce65f44a1a5727676d1c6b /src/libstd | |
| parent | 7ebf9bc5c22155d622537ded42b4ebf94238b296 (diff) | |
| parent | 724bf7bce2b35ac5731cf7e217c0e87916517b69 (diff) | |
| download | rust-0b6dbbc9cfb747df1db646bba16561c022704056.tar.gz rust-0b6dbbc9cfb747df1db646bba16561c022704056.zip | |
Auto merge of #21949 - japaric:index, r=nikomatsakis
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
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index aec9446773f..710f021d912 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1267,8 +1267,6 @@ impl<K, V, S, H, Q: ?Sized> IndexMut<Q> for HashMap<K, V, S> S: HashState<Hasher=H>, H: hash::Hasher<Output=u64> { - type Output = V; - #[inline] fn index_mut<'a>(&'a mut self, index: &Q) -> &'a mut V { self.get_mut(index).expect("no entry found for key") |
