From 1d356624a1c03363be37886ffdad7dcf25ee81f6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 23 Oct 2014 08:42:21 -0700 Subject: collections: Enable IndexMut for some collections This commit enables implementations of IndexMut for a number of collections, including Vec, RingBuf, SmallIntMap, TrieMap, TreeMap, and HashMap. At the same time this deprecates the `get_mut` methods on vectors in favor of using the indexing notation. cc #18424 --- src/libsync/comm/sync.rs | 4 ++-- src/libsync/raw.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libsync') diff --git a/src/libsync/comm/sync.rs b/src/libsync/comm/sync.rs index bbb4813f5f9..42de6f66289 100644 --- a/src/libsync/comm/sync.rs +++ b/src/libsync/comm/sync.rs @@ -426,7 +426,7 @@ impl Buffer { fn enqueue(&mut self, t: T) { let pos = (self.start + self.size) % self.buf.len(); self.size += 1; - let prev = mem::replace(self.buf.get_mut(pos), Some(t)); + let prev = mem::replace(&mut self.buf[pos], Some(t)); assert!(prev.is_none()); } @@ -434,7 +434,7 @@ impl Buffer { let start = self.start; self.size -= 1; self.start = (self.start + 1) % self.buf.len(); - self.buf.get_mut(start).take().unwrap() + self.buf[start].take().unwrap() } fn size(&self) -> uint { self.size } diff --git a/src/libsync/raw.rs b/src/libsync/raw.rs index 4fd62ac3a1d..1410091b924 100644 --- a/src/libsync/raw.rs +++ b/src/libsync/raw.rs @@ -308,7 +308,7 @@ impl<'a> Condvar<'a> { // To avoid :broadcast_heavy, we make a new waitqueue, // swap it out with the old one, and broadcast on the // old one outside of the little-lock. - queue = Some(mem::replace(state.blocked.get_mut(condvar_id), + queue = Some(mem::replace(&mut state.blocked[condvar_id], WaitQueue::new())); } else { out_of_bounds = Some(state.blocked.len()); -- cgit 1.4.1-3-g733a5