@@ -116,10 +116,12 @@ pub trait Buildable<A> {
116
116
}
117
117
118
118
#[ inline( always) ]
119
- pub fn _eachi < A , IA : BaseIter < A > > ( self : & IA , blk : & fn ( uint , & A ) -> bool ) -> bool {
119
+ pub fn _eachi < A , IA : BaseIter < A > > ( this : & IA , blk : & fn ( uint , & A ) -> bool ) -> bool {
120
120
let mut i = 0 ;
121
- for self . each |a| {
122
- if !blk ( i, a) { return false ; }
121
+ for this. each |a| {
122
+ if !blk ( i, a) {
123
+ return false ;
124
+ }
123
125
i += 1 ;
124
126
}
125
127
return true ;
@@ -135,47 +137,47 @@ pub fn eachi<A,IA:BaseIter<A>>(self: &IA, blk: &fn(uint, &A) -> bool) -> bool {
135
137
}
136
138
137
139
#[ inline( always) ]
138
- pub fn all < A , IA : BaseIter < A > > ( self : & IA , blk : & fn ( & A ) -> bool ) -> bool {
139
- for self . each |a| {
140
+ pub fn all < A , IA : BaseIter < A > > ( this : & IA , blk : & fn ( & A ) -> bool ) -> bool {
141
+ for this . each |a| {
140
142
if !blk ( a) { return false ; }
141
143
}
142
144
return true ;
143
145
}
144
146
145
147
#[ inline( always) ]
146
- pub fn any < A , IA : BaseIter < A > > ( self : & IA , blk : & fn ( & A ) -> bool ) -> bool {
147
- for self . each |a| {
148
+ pub fn any < A , IA : BaseIter < A > > ( this : & IA , blk : & fn ( & A ) -> bool ) -> bool {
149
+ for this . each |a| {
148
150
if blk ( a) { return true ; }
149
151
}
150
152
return false ;
151
153
}
152
154
153
155
#[ inline( always) ]
154
- pub fn filter_to_vec < A : Copy , IA : BaseIter < A > > ( self : & IA ,
156
+ pub fn filter_to_vec < A : Copy , IA : BaseIter < A > > ( this : & IA ,
155
157
prd : & fn ( & A ) -> bool )
156
158
-> ~[ A ] {
157
- do vec:: build_sized_opt ( self . size_hint ( ) ) |push| {
158
- for self . each |a| {
159
+ do vec:: build_sized_opt ( this . size_hint ( ) ) |push| {
160
+ for this . each |a| {
159
161
if prd ( a) { push ( * a) ; }
160
162
}
161
163
}
162
164
}
163
165
164
166
#[ inline( always) ]
165
- pub fn map_to_vec < A , B , IA : BaseIter < A > > ( self : & IA , op : & fn ( & A ) -> B ) -> ~[ B ] {
166
- do vec:: build_sized_opt ( self . size_hint ( ) ) |push| {
167
- for self . each |a| {
167
+ pub fn map_to_vec < A , B , IA : BaseIter < A > > ( this : & IA , op : & fn ( & A ) -> B ) -> ~[ B ] {
168
+ do vec:: build_sized_opt ( this . size_hint ( ) ) |push| {
169
+ for this . each |a| {
168
170
push( op( a) ) ;
169
171
}
170
172
}
171
173
}
172
174
173
175
#[ inline( always) ]
174
- pub fn flat_map_to_vec < A , B , IA : BaseIter < A > , IB : BaseIter < B > > ( self : & IA ,
176
+ pub fn flat_map_to_vec < A , B , IA : BaseIter < A > , IB : BaseIter < B > > ( this : & IA ,
175
177
op : & fn ( & A ) -> IB )
176
178
-> ~[ B ] {
177
179
do vec:: build |push| {
178
- for self . each |a| {
180
+ for this . each |a| {
179
181
for op( a) . each |& b| {
180
182
push( b) ;
181
183
}
@@ -184,31 +186,31 @@ pub fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(self: &IA,
184
186
}
185
187
186
188
#[ inline( always) ]
187
- pub fn foldl < A , B , IA : BaseIter < A > > ( self : & IA , b0 : B , blk : & fn ( & B , & A ) -> B )
189
+ pub fn foldl < A , B , IA : BaseIter < A > > ( this : & IA , b0 : B , blk : & fn ( & B , & A ) -> B )
188
190
-> B {
189
191
let mut b = b0;
190
- for self . each |a| {
192
+ for this . each |a| {
191
193
b = blk ( & b, a) ;
192
194
}
193
195
b
194
196
}
195
197
196
198
#[ inline( always) ]
197
- pub fn to_vec < A : Copy , IA : BaseIter < A > > ( self : & IA ) -> ~[ A ] {
198
- map_to_vec ( self , |& x| x)
199
+ pub fn to_vec < A : Copy , IA : BaseIter < A > > ( this : & IA ) -> ~[ A ] {
200
+ map_to_vec ( this , |& x| x)
199
201
}
200
202
201
203
#[ inline( always) ]
202
- pub fn contains < A : Eq , IA : BaseIter < A > > ( self : & IA , x : & A ) -> bool {
203
- for self . each |a| {
204
+ pub fn contains < A : Eq , IA : BaseIter < A > > ( this : & IA , x : & A ) -> bool {
205
+ for this . each |a| {
204
206
if * a == * x { return true ; }
205
207
}
206
208
return false ;
207
209
}
208
210
209
211
#[ inline( always) ]
210
- pub fn count < A : Eq , IA : BaseIter < A > > ( self : & IA , x : & A ) -> uint {
211
- do foldl ( self , 0 ) |count, value| {
212
+ pub fn count < A : Eq , IA : BaseIter < A > > ( this : & IA , x : & A ) -> uint {
213
+ do foldl ( this , 0 ) |count, value| {
212
214
if * value == * x {
213
215
* count + 1
214
216
} else {
@@ -218,10 +220,10 @@ pub fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint {
218
220
}
219
221
220
222
#[ inline( always) ]
221
- pub fn position < A , IA : BaseIter < A > > ( self : & IA , f : & fn ( & A ) -> bool )
223
+ pub fn position < A , IA : BaseIter < A > > ( this : & IA , f : & fn ( & A ) -> bool )
222
224
-> Option < uint > {
223
225
let mut i = 0 ;
224
- for self . each |a| {
226
+ for this . each |a| {
225
227
if f ( a) { return Some ( i) ; }
226
228
i += 1 ;
227
229
}
@@ -253,8 +255,8 @@ pub fn repeat(times: uint, blk: &fn() -> bool) -> bool {
253
255
}
254
256
255
257
#[ inline( always) ]
256
- pub fn min < A : Copy + Ord , IA : BaseIter < A > > ( self : & IA ) -> A {
257
- match do foldl :: < A , Option < A > , IA > ( self , None ) |a, b| {
258
+ pub fn min < A : Copy + Ord , IA : BaseIter < A > > ( this : & IA ) -> A {
259
+ match do foldl :: < A , Option < A > , IA > ( this , None ) |a, b| {
258
260
match a {
259
261
& Some ( ref a_) if * a_ < * b => {
260
262
* ( a)
@@ -268,8 +270,8 @@ pub fn min<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
268
270
}
269
271
270
272
#[inline(always)]
271
- pub fn max<A:Copy + Ord,IA:BaseIter<A>>(self : &IA) -> A {
272
- match do foldl::<A,Option<A>,IA>(self , None) |a, b| {
273
+ pub fn max<A:Copy + Ord,IA:BaseIter<A>>(this : &IA) -> A {
274
+ match do foldl::<A,Option<A>,IA>(this , None) |a, b| {
273
275
match a {
274
276
&Some(ref a_) if *a_ > *b => {
275
277
*(a)
@@ -283,9 +285,9 @@ pub fn max<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
283
285
}
284
286
285
287
#[ inline( always) ]
286
- pub fn find < A : Copy , IA : BaseIter < A > > ( self : & IA , f : & fn ( & A ) -> bool )
288
+ pub fn find < A : Copy , IA : BaseIter < A > > ( this : & IA , f : & fn ( & A ) -> bool )
287
289
-> Option < A > {
288
- for self . each |i| {
290
+ for this . each |i| {
289
291
if f ( i) { return Some ( * i) }
290
292
}
291
293
return None ;
0 commit comments