diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-11-28 13:51:50 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-12-04 14:51:31 -0800 |
| commit | d1ebdbeb6c00fe7d119ce17cabb303c5731f9bf7 (patch) | |
| tree | bde6bd5862f6838776d2176e52ea96235828e348 /src/libstd | |
| parent | 56ece46f7de9d1703dd39f952afac9bed22633b6 (diff) | |
| download | rust-d1ebdbeb6c00fe7d119ce17cabb303c5731f9bf7.tar.gz rust-d1ebdbeb6c00fe7d119ce17cabb303c5731f9bf7.zip | |
librustc: Implement explicit self for Add and Index; add a hack in the borrow checker to support this. r=nmatsakis
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/bitv.rs | 8 | ||||
| -rw-r--r-- | src/libstd/ebml.rs | 10 | ||||
| -rw-r--r-- | src/libstd/map.rs | 10 | ||||
| -rw-r--r-- | src/libstd/smallintmap.rs | 10 |
4 files changed, 38 insertions, 0 deletions
diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index e9ff56df30d..72f21a687da 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -565,11 +565,19 @@ pure fn land(w0: uint, w1: uint) -> uint { return w0 & w1; } pure fn right(_w0: uint, w1: uint) -> uint { return w1; } +#[cfg(stage0)] impl Bitv: ops::Index<uint,bool> { pure fn index(i: uint) -> bool { self.get(i) } } +#[cfg(stage1)] +#[cfg(stage2)] +impl Bitv: ops::Index<uint,bool> { + pure fn index(&self, i: uint) -> bool { + self.get(i) + } +} #[cfg(test)] mod tests { diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 1bfba2c7b0c..3b65f913755 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -57,6 +57,7 @@ pub mod Reader { // ebml reading + #[cfg(stage0)] impl Doc: ops::Index<uint,Doc> { pure fn index(tag: uint) -> Doc { unsafe { @@ -64,6 +65,15 @@ pub mod Reader { } } } + #[cfg(stage1)] + #[cfg(stage2)] + impl Doc: ops::Index<uint,Doc> { + pure fn index(&self, tag: uint) -> Doc { + unsafe { + get_doc(*self, tag) + } + } + } fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { let a = data[start]; diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 05a8e37d9af..add1976539c 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -429,6 +429,7 @@ pub mod chained { } } + #[cfg(stage0)] impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: ops::Index<K, V> { pure fn index(k: K) -> V { unsafe { @@ -436,6 +437,15 @@ pub mod chained { } } } + #[cfg(stage1)] + #[cfg(stage2)] + impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: ops::Index<K, V> { + pure fn index(&self, k: K) -> V { + unsafe { + self.get(k) + } + } + } fn chains<K,V>(nchains: uint) -> ~[mut Option<@Entry<K,V>>] { vec::to_mut(vec::from_elem(nchains, None)) diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index b83387a87ba..3e82c3c9419 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -150,6 +150,7 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> { } } +#[cfg(stage0)] impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> { pure fn index(key: uint) -> V { unsafe { @@ -157,6 +158,15 @@ impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> { } } } +#[cfg(stage1)] +#[cfg(stage2)] +impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> { + pure fn index(&self, key: uint) -> V { + unsafe { + get(*self, key) + } + } +} /// Cast the given smallintmap to a map::map pub fn as_map<V: Copy>(s: SmallIntMap<V>) -> map::Map<uint, V> { |
