@@ -43,7 +43,7 @@ use default::Default;
43
43
use iter:: * ;
44
44
use kinds:: Copy ;
45
45
use num:: Int ;
46
- use ops;
46
+ use ops:: { FnMut , mod } ;
47
47
use option:: Option ;
48
48
use option:: Option :: { None , Some } ;
49
49
use ptr;
@@ -105,20 +105,23 @@ pub trait SlicePrelude<T> for Sized? {
105
105
/// Returns an iterator over subslices separated by elements that match
106
106
/// `pred`. The matched element is not contained in the subslices.
107
107
#[ unstable = "iterator type may change, waiting on unboxed closures" ]
108
- fn split < ' a > ( & ' a self , pred: |& T |: ' a -> bool ) -> Splits <' a, T >;
108
+ fn split < ' a , P > ( & ' a self , pred : P ) -> Splits < ' a , T , P > where
109
+ P : FnMut ( & T ) -> bool ;
109
110
110
111
/// Returns an iterator over subslices separated by elements that match
111
112
/// `pred`, limited to splitting at most `n` times. The matched element is
112
113
/// not contained in the subslices.
113
114
#[ unstable = "iterator type may change" ]
114
- fn splitn < ' a > ( & ' a self , n : uint , pred: |& T |: ' a -> bool ) -> SplitsN <Splits <' a, T >>;
115
+ fn splitn < ' a , P > ( & ' a self , n : uint , pred : P ) -> SplitsN < Splits < ' a , T , P > > where
116
+ P : FnMut ( & T ) -> bool ;
115
117
116
118
/// Returns an iterator over subslices separated by elements that match
117
119
/// `pred` limited to splitting at most `n` times. This starts at the end of
118
120
/// the slice and works backwards. The matched element is not contained in
119
121
/// the subslices.
120
122
#[ unstable = "iterator type may change" ]
121
- fn rsplitn < ' a > ( & ' a self , n : uint , pred: |& T |: ' a -> bool ) -> SplitsN <Splits <' a, T >>;
123
+ fn rsplitn < ' a , P > ( & ' a self , n : uint , pred : P ) -> SplitsN < Splits < ' a , T , P > > where
124
+ P : FnMut ( & T ) -> bool ;
122
125
123
126
/// Returns an iterator over all contiguous windows of length
124
127
/// `size`. The windows overlap. If the slice is shorter than
@@ -470,7 +473,7 @@ impl<T> SlicePrelude<T> for [T] {
470
473
}
471
474
472
475
#[ inline]
473
- fn split < ' a > ( & ' a self , pred: | & T | : ' a -> bool ) -> Splits <' a, T > {
476
+ fn split < ' a , P > ( & ' a self , pred : P ) -> Splits < ' a , T , P > where P : FnMut ( & T ) -> bool {
474
477
Splits {
475
478
v : self ,
476
479
pred : pred,
@@ -479,7 +482,9 @@ impl<T> SlicePrelude<T> for [T] {
479
482
}
480
483
481
484
#[ inline]
482
- fn splitn < ' a > ( & ' a self , n : uint , pred: |& T |: ' a -> bool ) -> SplitsN <Splits <' a, T >> {
485
+ fn splitn < ' a , P > ( & ' a self , n : uint , pred : P ) -> SplitsN < Splits < ' a , T , P > > where
486
+ P : FnMut ( & T ) -> bool ,
487
+ {
483
488
SplitsN {
484
489
iter : self . split ( pred) ,
485
490
count : n,
@@ -488,7 +493,9 @@ impl<T> SlicePrelude<T> for [T] {
488
493
}
489
494
490
495
#[ inline]
491
- fn rsplitn < ' a > ( & ' a self , n : uint , pred: |& T |: ' a -> bool ) -> SplitsN <Splits <' a, T >> {
496
+ fn rsplitn < ' a , P > ( & ' a self , n : uint , pred : P ) -> SplitsN < Splits < ' a , T , P > > where
497
+ P : FnMut ( & T ) -> bool ,
498
+ {
492
499
SplitsN {
493
500
iter : self . split ( pred) ,
494
501
count : n,
@@ -1271,14 +1278,14 @@ trait SplitsIter<E>: DoubleEndedIterator<E> {
1271
1278
/// An iterator over subslices separated by elements that match a predicate
1272
1279
/// function.
1273
1280
#[ experimental = "needs review" ]
1274
- pub struct Splits < ' a , T : ' a > {
1281
+ pub struct Splits < ' a , T : ' a , P > where P : FnMut ( & T ) -> bool {
1275
1282
v : & ' a [ T ] ,
1276
- pred : | t : & T | : ' a -> bool ,
1283
+ pred : P ,
1277
1284
finished : bool
1278
1285
}
1279
1286
1280
1287
#[ experimental = "needs review" ]
1281
- impl < ' a , T > Iterator < & ' a [ T ] > for Splits < ' a , T > {
1288
+ impl < ' a , T , P > Iterator < & ' a [ T ] > for Splits < ' a , T , P > where P : FnMut ( & T ) -> bool {
1282
1289
#[ inline]
1283
1290
fn next ( & mut self ) -> Option < & ' a [ T ] > {
1284
1291
if self . finished { return None ; }
@@ -1304,7 +1311,7 @@ impl<'a, T> Iterator<&'a [T]> for Splits<'a, T> {
1304
1311
}
1305
1312
1306
1313
#[ experimental = "needs review" ]
1307
- impl < ' a , T > DoubleEndedIterator < & ' a [ T ] > for Splits < ' a , T > {
1314
+ impl < ' a , T , P > DoubleEndedIterator < & ' a [ T ] > for Splits < ' a , T , P > where P : FnMut ( & T ) -> bool {
1308
1315
#[ inline]
1309
1316
fn next_back ( & mut self ) -> Option < & ' a [ T ] > {
1310
1317
if self . finished { return None ; }
@@ -1320,7 +1327,7 @@ impl<'a, T> DoubleEndedIterator<&'a [T]> for Splits<'a, T> {
1320
1327
}
1321
1328
}
1322
1329
1323
- impl < ' a , T > SplitsIter < & ' a [ T ] > for Splits < ' a , T > {
1330
+ impl < ' a , T , P > SplitsIter < & ' a [ T ] > for Splits < ' a , T , P > where P : FnMut ( & T ) -> bool {
1324
1331
#[ inline]
1325
1332
fn finish ( & mut self ) -> Option < & ' a [ T ] > {
1326
1333
if self . finished { None } else { self . finished = true ; Some ( self . v ) }
0 commit comments