mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 19:53:46 +00:00
collections: fix fallout
This commit is contained in:
parent
234dc4d4dd
commit
32dd592d36
@ -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
|
||||
|
@ -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> {
|
||||
|
@ -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> {
|
||||
|
@ -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] {
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user