From 5fe0bb743a0af0413f8989a70a4f926fa5c63074 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Fri, 20 Mar 2015 10:22:57 -0700 Subject: Future-proof indexing on maps: remove IndexMut 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 --- src/libstd/collections/hash/map.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'src/libstd') 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 Index for HashMap } } -#[stable(feature = "rust1", since = "1.0.0")] -impl IndexMut for HashMap - where K: Eq + Hash + Borrow, - 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> { -- cgit 1.4.1-3-g733a5 From 84b14c5dc9bceeadb24beaa5ae1b126701b7d932 Mon Sep 17 00:00:00 2001 From: Barosl Lee Date: Sat, 21 Mar 2015 14:38:23 +0900 Subject: Fix documentation for std::sync::mutex: into_guard -> into_inner --- src/libstd/sync/mutex.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 1cbfbbf2927..130fd1d7dc8 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -40,7 +40,7 @@ use fmt; /// among threads to ensure that a possibly invalid invariant is not witnessed. /// /// A poisoned mutex, however, does not prevent all access to the underlying -/// data. The `PoisonError` type has an `into_guard` method which will return +/// data. The `PoisonError` type has an `into_inner` method which will return /// the guard that would have otherwise been returned on a successful lock. This /// allows access to the data, despite the lock being poisoned. /// @@ -105,7 +105,7 @@ use fmt; /// // pattern matched on to return the underlying guard on both branches. /// let mut guard = match lock.lock() { /// Ok(guard) => guard, -/// Err(poisoned) => poisoned.into_guard(), +/// Err(poisoned) => poisoned.into_inner(), /// }; /// /// *guard += 1; -- cgit 1.4.1-3-g733a5