about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2015-01-03 10:40:10 -0500
committerJorge Aparicio <japaricious@gmail.com>2015-01-03 16:30:49 -0500
commit32dd592d36c731fd3bbd0cda8040d33b44a90f4b (patch)
tree1b42124db43d375426eca6893e0f5165689ea5f2 /src
parent234dc4d4ddc19466ec3393210c2949d8ca0eba41 (diff)
downloadrust-32dd592d36c731fd3bbd0cda8040d33b44a90f4b.tar.gz
rust-32dd592d36c731fd3bbd0cda8040d33b44a90f4b.zip
collections: fix fallout
Diffstat (limited to 'src')
-rw-r--r--src/libcollections/bit.rs17
-rw-r--r--src/libcollections/btree/map.rs28
-rw-r--r--src/libcollections/ring_buf.rs26
-rw-r--r--src/libcollections/vec.rs25
-rw-r--r--src/libcollections/vec_map.rs25
5 files changed, 121 insertions, 0 deletions
diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs
index 5c52223bccd..9674885c857 100644
--- a/src/libcollections/bit.rs
+++ b/src/libcollections/bit.rs
@@ -164,6 +164,8 @@ pub struct Bitv {
     nbits: uint
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 // FIXME(Gankro): NopeNopeNopeNopeNope (wait for IndexGet to be a thing)
 impl Index<uint,bool> for Bitv {
     #[inline]
@@ -176,6 +178,21 @@ impl Index<uint,bool> for Bitv {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+// FIXME(Gankro): NopeNopeNopeNopeNope (wait for IndexGet to be a thing)
+impl Index<uint> for Bitv {
+    type Output = bool;
+
+    #[inline]
+    fn index(&self, i: &uint) -> &bool {
+        if self.get(*i).expect("index out of bounds") {
+            &TRUE
+        } else {
+            &FALSE
+        }
+    }
+}
+
 /// Computes how many blocks are needed to store that many bits
 fn blocks_for_bits(bits: uint) -> uint {
     // If we want 17 bits, dividing by 32 will produce 0. So we add 1 to make sure we
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs
index 13178893723..e86e9326665 100644
--- a/src/libcollections/btree/map.rs
+++ b/src/libcollections/btree/map.rs
@@ -898,6 +898,8 @@ impl<K: Show, V: Show> Show for BTreeMap<K, V> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 #[stable]
 impl<K: Ord, Sized? Q, V> Index<Q, V> for BTreeMap<K, V>
     where Q: BorrowFrom<K> + Ord
@@ -907,6 +909,20 @@ impl<K: Ord, Sized? Q, V> Index<Q, V> for BTreeMap<K, V>
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+#[stable]
+impl<K: Ord, Sized? Q, V> Index<Q> for BTreeMap<K, V>
+    where Q: BorrowFrom<K> + Ord
+{
+    type Output = V;
+
+    fn index(&self, key: &Q) -> &V {
+        self.get(key).expect("no entry found for key")
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 #[stable]
 impl<K: Ord, Sized? Q, V> IndexMut<Q, V> for BTreeMap<K, V>
     where Q: BorrowFrom<K> + Ord
@@ -916,6 +932,18 @@ impl<K: Ord, Sized? Q, V> IndexMut<Q, V> for BTreeMap<K, V>
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+#[stable]
+impl<K: Ord, Sized? Q, V> IndexMut<Q> for BTreeMap<K, V>
+    where Q: BorrowFrom<K> + Ord
+{
+    type Output = V;
+
+    fn index_mut(&mut self, key: &Q) -> &mut V {
+        self.get_mut(key).expect("no entry found for key")
+    }
+}
+
 /// Genericises over how to get the correct type of iterator from the correct type
 /// of Node ownership.
 trait Traverse<N> {
diff --git a/src/libcollections/ring_buf.rs b/src/libcollections/ring_buf.rs
index eb58edbe453..dd78ae03c5a 100644
--- a/src/libcollections/ring_buf.rs
+++ b/src/libcollections/ring_buf.rs
@@ -1372,6 +1372,8 @@ impl<S: Writer, A: Hash<S>> Hash<S> for RingBuf<A> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 #[stable]
 impl<A> Index<uint, A> for RingBuf<A> {
     #[inline]
@@ -1380,6 +1382,19 @@ impl<A> Index<uint, A> for RingBuf<A> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+#[stable]
+impl<A> Index<uint> for RingBuf<A> {
+    type Output = A;
+
+    #[inline]
+    fn index<'a>(&'a self, i: &uint) -> &'a A {
+        self.get(*i).expect("Out of bounds access")
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 #[stable]
 impl<A> IndexMut<uint, A> for RingBuf<A> {
     #[inline]
@@ -1388,6 +1403,17 @@ impl<A> IndexMut<uint, A> for RingBuf<A> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+#[stable]
+impl<A> IndexMut<uint> for RingBuf<A> {
+    type Output = A;
+
+    #[inline]
+    fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut A {
+        self.get_mut(*i).expect("Out of bounds access")
+    }
+}
+
 #[stable]
 impl<A> FromIterator<A> for RingBuf<A> {
     fn from_iter<T: Iterator<Item=A>>(iterator: T) -> RingBuf<A> {
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 39eb37e3dd9..07338801872 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -1245,6 +1245,8 @@ impl<S: hash::Writer, T: Hash<S>> Hash<S> for Vec<T> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 #[experimental = "waiting on Index stability"]
 impl<T> Index<uint,T> for Vec<T> {
     #[inline]
@@ -1253,6 +1255,19 @@ impl<T> Index<uint,T> for Vec<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+#[experimental = "waiting on Index stability"]
+impl<T> Index<uint> for Vec<T> {
+    type Output = T;
+
+    #[inline]
+    fn index<'a>(&'a self, index: &uint) -> &'a T {
+        &self.as_slice()[*index]
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<T> IndexMut<uint,T> for Vec<T> {
     #[inline]
     fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut T {
@@ -1260,6 +1275,16 @@ impl<T> IndexMut<uint,T> for Vec<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<T> IndexMut<uint> for Vec<T> {
+    type Output = T;
+
+    #[inline]
+    fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut T {
+        &mut self.as_mut_slice()[*index]
+    }
+}
+
 impl<T> ops::Slice<uint, [T]> for Vec<T> {
     #[inline]
     fn as_slice_<'a>(&'a self) -> &'a [T] {
diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs
index bf0c8f10e5f..91edbc7b54e 100644
--- a/src/libcollections/vec_map.rs
+++ b/src/libcollections/vec_map.rs
@@ -562,6 +562,8 @@ impl<V> Extend<(uint, V)> for VecMap<V> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 #[stable]
 impl<V> Index<uint, V> for VecMap<V> {
     #[inline]
@@ -570,6 +572,18 @@ impl<V> Index<uint, V> for VecMap<V> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<V> Index<uint> for VecMap<V> {
+    type Output = V;
+
+    #[inline]
+    fn index<'a>(&'a self, i: &uint) -> &'a V {
+        self.get(i).expect("key not present")
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 #[stable]
 impl<V> IndexMut<uint, V> for VecMap<V> {
     #[inline]
@@ -578,6 +592,17 @@ impl<V> IndexMut<uint, V> for VecMap<V> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+#[stable]
+impl<V> IndexMut<uint> for VecMap<V> {
+    type Output = V;
+
+    #[inline]
+    fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut V {
+        self.get_mut(i).expect("key not present")
+    }
+}
+
 macro_rules! iterator {
     (impl $name:ident -> $elem:ty, $($getter:ident),+) => {
         #[stable]