diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-05-10 15:15:06 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-05-12 16:35:18 -0700 |
| commit | 5d3559e6455757c5508bba5b5add69477ebac53e (patch) | |
| tree | 71e166364df7f828c4c98c5853597d2c62c37fac /src/libcore/old_iter.rs | |
| parent | 06ef889cdc77db862d526bf6a607ecdf3ee80beb (diff) | |
| download | rust-5d3559e6455757c5508bba5b5add69477ebac53e.tar.gz rust-5d3559e6455757c5508bba5b5add69477ebac53e.zip | |
librustc: Make `self` and `static` into keywords
Diffstat (limited to 'src/libcore/old_iter.rs')
| -rw-r--r-- | src/libcore/old_iter.rs | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/src/libcore/old_iter.rs b/src/libcore/old_iter.rs index a596b07dc78..95bc8872c91 100644 --- a/src/libcore/old_iter.rs +++ b/src/libcore/old_iter.rs @@ -116,10 +116,12 @@ pub trait Buildable<A> { } #[inline(always)] -pub fn _eachi<A,IA:BaseIter<A>>(self: &IA, blk: &fn(uint, &A) -> bool) -> bool { +pub fn _eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool { let mut i = 0; - for self.each |a| { - if !blk(i, a) { return false; } + for this.each |a| { + if !blk(i, a) { + return false; + } i += 1; } return true; @@ -135,47 +137,47 @@ pub fn eachi<A,IA:BaseIter<A>>(self: &IA, blk: &fn(uint, &A) -> bool) -> bool { } #[inline(always)] -pub fn all<A,IA:BaseIter<A>>(self: &IA, blk: &fn(&A) -> bool) -> bool { - for self.each |a| { +pub fn all<A,IA:BaseIter<A>>(this: &IA, blk: &fn(&A) -> bool) -> bool { + for this.each |a| { if !blk(a) { return false; } } return true; } #[inline(always)] -pub fn any<A,IA:BaseIter<A>>(self: &IA, blk: &fn(&A) -> bool) -> bool { - for self.each |a| { +pub fn any<A,IA:BaseIter<A>>(this: &IA, blk: &fn(&A) -> bool) -> bool { + for this.each |a| { if blk(a) { return true; } } return false; } #[inline(always)] -pub fn filter_to_vec<A:Copy,IA:BaseIter<A>>(self: &IA, +pub fn filter_to_vec<A:Copy,IA:BaseIter<A>>(this: &IA, prd: &fn(&A) -> bool) -> ~[A] { - do vec::build_sized_opt(self.size_hint()) |push| { - for self.each |a| { + do vec::build_sized_opt(this.size_hint()) |push| { + for this.each |a| { if prd(a) { push(*a); } } } } #[inline(always)] -pub fn map_to_vec<A,B,IA:BaseIter<A>>(self: &IA, op: &fn(&A) -> B) -> ~[B] { - do vec::build_sized_opt(self.size_hint()) |push| { - for self.each |a| { +pub fn map_to_vec<A,B,IA:BaseIter<A>>(this: &IA, op: &fn(&A) -> B) -> ~[B] { + do vec::build_sized_opt(this.size_hint()) |push| { + for this.each |a| { push(op(a)); } } } #[inline(always)] -pub fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(self: &IA, +pub fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(this: &IA, op: &fn(&A) -> IB) -> ~[B] { do vec::build |push| { - for self.each |a| { + for this.each |a| { for op(a).each |&b| { push(b); } @@ -184,31 +186,31 @@ pub fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(self: &IA, } #[inline(always)] -pub fn foldl<A,B,IA:BaseIter<A>>(self: &IA, b0: B, blk: &fn(&B, &A) -> B) +pub fn foldl<A,B,IA:BaseIter<A>>(this: &IA, b0: B, blk: &fn(&B, &A) -> B) -> B { let mut b = b0; - for self.each |a| { + for this.each |a| { b = blk(&b, a); } b } #[inline(always)] -pub fn to_vec<A:Copy,IA:BaseIter<A>>(self: &IA) -> ~[A] { - map_to_vec(self, |&x| x) +pub fn to_vec<A:Copy,IA:BaseIter<A>>(this: &IA) -> ~[A] { + map_to_vec(this, |&x| x) } #[inline(always)] -pub fn contains<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> bool { - for self.each |a| { +pub fn contains<A:Eq,IA:BaseIter<A>>(this: &IA, x: &A) -> bool { + for this.each |a| { if *a == *x { return true; } } return false; } #[inline(always)] -pub fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint { - do foldl(self, 0) |count, value| { +pub fn count<A:Eq,IA:BaseIter<A>>(this: &IA, x: &A) -> uint { + do foldl(this, 0) |count, value| { if *value == *x { *count + 1 } else { @@ -218,10 +220,10 @@ pub fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint { } #[inline(always)] -pub fn position<A,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool) +pub fn position<A,IA:BaseIter<A>>(this: &IA, f: &fn(&A) -> bool) -> Option<uint> { let mut i = 0; - for self.each |a| { + for this.each |a| { if f(a) { return Some(i); } i += 1; } @@ -253,8 +255,8 @@ pub fn repeat(times: uint, blk: &fn() -> bool) -> bool { } #[inline(always)] -pub fn min<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A { - match do foldl::<A,Option<A>,IA>(self, None) |a, b| { +pub fn min<A:Copy + Ord,IA:BaseIter<A>>(this: &IA) -> A { + match do foldl::<A,Option<A>,IA>(this, None) |a, b| { match a { &Some(ref a_) if *a_ < *b => { *(a) @@ -268,8 +270,8 @@ pub fn min<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A { } #[inline(always)] -pub fn max<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A { - match do foldl::<A,Option<A>,IA>(self, None) |a, b| { +pub fn max<A:Copy + Ord,IA:BaseIter<A>>(this: &IA) -> A { + match do foldl::<A,Option<A>,IA>(this, None) |a, b| { match a { &Some(ref a_) if *a_ > *b => { *(a) @@ -283,9 +285,9 @@ pub fn max<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A { } #[inline(always)] -pub fn find<A:Copy,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool) +pub fn find<A:Copy,IA:BaseIter<A>>(this: &IA, f: &fn(&A) -> bool) -> Option<A> { - for self.each |i| { + for this.each |i| { if f(i) { return Some(*i) } } return None; |
