diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-22 01:35:39 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-23 04:54:26 +0530 |
| commit | a91eece96b1c945bebb01a7e906dabc2d736a131 (patch) | |
| tree | 5af8af886a8181ce78161da1b4cafda7277038e3 /src/libstd | |
| parent | b0aad7dd4fad8d7e2e2f877a511a637258949597 (diff) | |
| parent | 5fe0bb743a0af0413f8989a70a4f926fa5c63074 (diff) | |
| download | rust-a91eece96b1c945bebb01a7e906dabc2d736a131.tar.gz rust-a91eece96b1c945bebb01a7e906dabc2d736a131.zip | |
Rollup merge of #23559 - aturon:future-proof-map-index, r=Gankro
This commit removes the `IndexMut` impls on `HashMap` and `BTreeMap`, in order to future-proof the API against the eventual inclusion of an `IndexSet` trait. Ideally, we would eventually be able to support: ```rust map[owned_key] = val; map[borrowed_key].mutating_method(arguments); &mut map[borrowed_key]; ``` but to keep the design space as unconstrained as possible, we do not currently want to support `IndexMut`, in case some other strategy will eventually be needed. Code currently using mutating index notation can use `get_mut` instead. [breaking-change] Closes #23448 r? @Gankro
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 60b1738d2c9..9139e182ce4 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -23,7 +23,7 @@ use hash::{Hash, SipHasher}; use iter::{self, Iterator, ExactSizeIterator, IntoIterator, IteratorExt, FromIterator, Extend, Map}; use marker::Sized; use mem::{self, replace}; -use ops::{Deref, FnMut, Index, IndexMut}; +use ops::{Deref, FnMut, Index}; use option::Option::{self, Some, None}; use rand::{self, Rng}; use result::Result::{self, Ok, Err}; @@ -1258,18 +1258,6 @@ impl<K, Q: ?Sized, V, S> Index<Q> for HashMap<K, V, S> } } -#[stable(feature = "rust1", since = "1.0.0")] -impl<K, V, S, Q: ?Sized> IndexMut<Q> for HashMap<K, V, S> - where K: Eq + Hash + Borrow<Q>, - Q: Eq + Hash, - S: HashState, -{ - #[inline] - fn index_mut<'a>(&'a mut self, index: &Q) -> &'a mut V { - self.get_mut(index).expect("no entry found for key") - } -} - /// HashMap iterator. #[stable(feature = "rust1", since = "1.0.0")] pub struct Iter<'a, K: 'a, V: 'a> { |
