]> git.lizzy.rs Git - rust.git/commitdiff
std: fix fallout
authorJorge Aparicio <japaricious@gmail.com>
Sat, 3 Jan 2015 15:40:19 +0000 (10:40 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Sat, 3 Jan 2015 21:30:49 +0000 (16:30 -0500)
src/libstd/collections/hash/map.rs

index 6450b149d0242a961a5f66192986eca818aecce9..f246e9df3b9870b4b6f10cf2bbf2baf9aa81feba 100644 (file)
@@ -1300,6 +1300,8 @@ fn default() -> HashMap<K, V, H> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 #[stable]
 impl<K: Hash<S> + Eq, Sized? Q, V, S, H: Hasher<S>> Index<Q, V> for HashMap<K, V, H>
     where Q: BorrowFrom<K> + Hash<S> + Eq
@@ -1310,6 +1312,21 @@ fn index<'a>(&'a self, index: &Q) -> &'a V {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+#[stable]
+impl<K: Hash<S> + Eq, Sized? Q, V, S, H: Hasher<S>> Index<Q> for HashMap<K, V, H>
+    where Q: BorrowFrom<K> + Hash<S> + Eq
+{
+    type Output = V;
+
+    #[inline]
+    fn index<'a>(&'a self, index: &Q) -> &'a V {
+        self.get(index).expect("no entry found for key")
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 #[stable]
 impl<K: Hash<S> + Eq, Sized? Q, V, S, H: Hasher<S>> IndexMut<Q, V> for HashMap<K, V, H>
     where Q: BorrowFrom<K> + Hash<S> + Eq
@@ -1320,6 +1337,19 @@ fn index_mut<'a>(&'a mut self, index: &Q) -> &'a mut V {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+#[stable]
+impl<K: Hash<S> + Eq, Sized? Q, V, S, H: Hasher<S>> IndexMut<Q> for HashMap<K, V, H>
+    where Q: BorrowFrom<K> + Hash<S> + Eq
+{
+    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")
+    }
+}
+
 /// HashMap iterator
 #[stable]
 pub struct Iter<'a, K: 'a, V: 'a> {