Skip to content

Commit 32dd592

Browse files
author
Jorge Aparicio
committed
collections: fix fallout
1 parent 234dc4d commit 32dd592

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed

src/libcollections/bit.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ pub struct Bitv {
164164
nbits: uint
165165
}
166166

167+
// NOTE(stage0): remove impl after a snapshot
168+
#[cfg(stage0)]
167169
// FIXME(Gankro): NopeNopeNopeNopeNope (wait for IndexGet to be a thing)
168170
impl Index<uint,bool> for Bitv {
169171
#[inline]
@@ -176,6 +178,21 @@ impl Index<uint,bool> for Bitv {
176178
}
177179
}
178180

181+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
182+
// FIXME(Gankro): NopeNopeNopeNopeNope (wait for IndexGet to be a thing)
183+
impl Index<uint> for Bitv {
184+
type Output = bool;
185+
186+
#[inline]
187+
fn index(&self, i: &uint) -> &bool {
188+
if self.get(*i).expect("index out of bounds") {
189+
&TRUE
190+
} else {
191+
&FALSE
192+
}
193+
}
194+
}
195+
179196
/// Computes how many blocks are needed to store that many bits
180197
fn blocks_for_bits(bits: uint) -> uint {
181198
// If we want 17 bits, dividing by 32 will produce 0. So we add 1 to make sure we

src/libcollections/btree/map.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,8 @@ impl<K: Show, V: Show> Show for BTreeMap<K, V> {
898898
}
899899
}
900900

901+
// NOTE(stage0): remove impl after a snapshot
902+
#[cfg(stage0)]
901903
#[stable]
902904
impl<K: Ord, Sized? Q, V> Index<Q, V> for BTreeMap<K, V>
903905
where Q: BorrowFrom<K> + Ord
@@ -907,6 +909,20 @@ impl<K: Ord, Sized? Q, V> Index<Q, V> for BTreeMap<K, V>
907909
}
908910
}
909911

912+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
913+
#[stable]
914+
impl<K: Ord, Sized? Q, V> Index<Q> for BTreeMap<K, V>
915+
where Q: BorrowFrom<K> + Ord
916+
{
917+
type Output = V;
918+
919+
fn index(&self, key: &Q) -> &V {
920+
self.get(key).expect("no entry found for key")
921+
}
922+
}
923+
924+
// NOTE(stage0): remove impl after a snapshot
925+
#[cfg(stage0)]
910926
#[stable]
911927
impl<K: Ord, Sized? Q, V> IndexMut<Q, V> for BTreeMap<K, V>
912928
where Q: BorrowFrom<K> + Ord
@@ -916,6 +932,18 @@ impl<K: Ord, Sized? Q, V> IndexMut<Q, V> for BTreeMap<K, V>
916932
}
917933
}
918934

935+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
936+
#[stable]
937+
impl<K: Ord, Sized? Q, V> IndexMut<Q> for BTreeMap<K, V>
938+
where Q: BorrowFrom<K> + Ord
939+
{
940+
type Output = V;
941+
942+
fn index_mut(&mut self, key: &Q) -> &mut V {
943+
self.get_mut(key).expect("no entry found for key")
944+
}
945+
}
946+
919947
/// Genericises over how to get the correct type of iterator from the correct type
920948
/// of Node ownership.
921949
trait Traverse<N> {

src/libcollections/ring_buf.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,8 @@ impl<S: Writer, A: Hash<S>> Hash<S> for RingBuf<A> {
13721372
}
13731373
}
13741374

1375+
// NOTE(stage0): remove impl after a snapshot
1376+
#[cfg(stage0)]
13751377
#[stable]
13761378
impl<A> Index<uint, A> for RingBuf<A> {
13771379
#[inline]
@@ -1380,6 +1382,19 @@ impl<A> Index<uint, A> for RingBuf<A> {
13801382
}
13811383
}
13821384

1385+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
1386+
#[stable]
1387+
impl<A> Index<uint> for RingBuf<A> {
1388+
type Output = A;
1389+
1390+
#[inline]
1391+
fn index<'a>(&'a self, i: &uint) -> &'a A {
1392+
self.get(*i).expect("Out of bounds access")
1393+
}
1394+
}
1395+
1396+
// NOTE(stage0): remove impl after a snapshot
1397+
#[cfg(stage0)]
13831398
#[stable]
13841399
impl<A> IndexMut<uint, A> for RingBuf<A> {
13851400
#[inline]
@@ -1388,6 +1403,17 @@ impl<A> IndexMut<uint, A> for RingBuf<A> {
13881403
}
13891404
}
13901405

1406+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
1407+
#[stable]
1408+
impl<A> IndexMut<uint> for RingBuf<A> {
1409+
type Output = A;
1410+
1411+
#[inline]
1412+
fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut A {
1413+
self.get_mut(*i).expect("Out of bounds access")
1414+
}
1415+
}
1416+
13911417
#[stable]
13921418
impl<A> FromIterator<A> for RingBuf<A> {
13931419
fn from_iter<T: Iterator<Item=A>>(iterator: T) -> RingBuf<A> {

src/libcollections/vec.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,8 @@ impl<S: hash::Writer, T: Hash<S>> Hash<S> for Vec<T> {
12451245
}
12461246
}
12471247

1248+
// NOTE(stage0): remove impl after a snapshot
1249+
#[cfg(stage0)]
12481250
#[experimental = "waiting on Index stability"]
12491251
impl<T> Index<uint,T> for Vec<T> {
12501252
#[inline]
@@ -1253,13 +1255,36 @@ impl<T> Index<uint,T> for Vec<T> {
12531255
}
12541256
}
12551257

1258+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
1259+
#[experimental = "waiting on Index stability"]
1260+
impl<T> Index<uint> for Vec<T> {
1261+
type Output = T;
1262+
1263+
#[inline]
1264+
fn index<'a>(&'a self, index: &uint) -> &'a T {
1265+
&self.as_slice()[*index]
1266+
}
1267+
}
1268+
1269+
// NOTE(stage0): remove impl after a snapshot
1270+
#[cfg(stage0)]
12561271
impl<T> IndexMut<uint,T> for Vec<T> {
12571272
#[inline]
12581273
fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut T {
12591274
&mut self.as_mut_slice()[*index]
12601275
}
12611276
}
12621277

1278+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
1279+
impl<T> IndexMut<uint> for Vec<T> {
1280+
type Output = T;
1281+
1282+
#[inline]
1283+
fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut T {
1284+
&mut self.as_mut_slice()[*index]
1285+
}
1286+
}
1287+
12631288
impl<T> ops::Slice<uint, [T]> for Vec<T> {
12641289
#[inline]
12651290
fn as_slice_<'a>(&'a self) -> &'a [T] {

src/libcollections/vec_map.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ impl<V> Extend<(uint, V)> for VecMap<V> {
562562
}
563563
}
564564

565+
// NOTE(stage0): remove impl after a snapshot
566+
#[cfg(stage0)]
565567
#[stable]
566568
impl<V> Index<uint, V> for VecMap<V> {
567569
#[inline]
@@ -570,6 +572,18 @@ impl<V> Index<uint, V> for VecMap<V> {
570572
}
571573
}
572574

575+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
576+
impl<V> Index<uint> for VecMap<V> {
577+
type Output = V;
578+
579+
#[inline]
580+
fn index<'a>(&'a self, i: &uint) -> &'a V {
581+
self.get(i).expect("key not present")
582+
}
583+
}
584+
585+
// NOTE(stage0): remove impl after a snapshot
586+
#[cfg(stage0)]
573587
#[stable]
574588
impl<V> IndexMut<uint, V> for VecMap<V> {
575589
#[inline]
@@ -578,6 +592,17 @@ impl<V> IndexMut<uint, V> for VecMap<V> {
578592
}
579593
}
580594

595+
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
596+
#[stable]
597+
impl<V> IndexMut<uint> for VecMap<V> {
598+
type Output = V;
599+
600+
#[inline]
601+
fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut V {
602+
self.get_mut(i).expect("key not present")
603+
}
604+
}
605+
581606
macro_rules! iterator {
582607
(impl $name:ident -> $elem:ty, $($getter:ident),+) => {
583608
#[stable]

0 commit comments

Comments
 (0)