@@ -174,7 +174,7 @@ impl<'a> Iterator<(uint, u32)> for MaskWords<'a> {
174
174
175
175
impl Bitv {
176
176
#[ inline]
177
- fn process ( & mut self , other : & Bitv , op : | u32 , u32| -> u32) -> bool {
177
+ fn process < F > ( & mut self , other : & Bitv , mut op : F ) -> bool where F : FnMut ( u32 , u32 ) -> u32 {
178
178
let len = other. storage . len ( ) ;
179
179
assert_eq ! ( self . storage. len( ) , len) ;
180
180
let mut changed = false ;
@@ -816,7 +816,7 @@ pub fn from_bytes(bytes: &[u8]) -> Bitv {
816
816
/// let bv = from_fn(5, |i| { i % 2 == 0 });
817
817
/// assert!(bv.eq_vec(&[true, false, true, false, true]));
818
818
/// ```
819
- pub fn from_fn ( len : uint , f: |index : uint | -> bool ) -> Bitv {
819
+ pub fn from_fn < F > ( len : uint , mut f : F ) -> Bitv where F : FnMut ( uint ) -> bool {
820
820
let mut bitv = Bitv :: with_capacity ( len, false ) ;
821
821
for i in range ( 0 u, len) {
822
822
bitv. set ( i, f ( i) ) ;
@@ -1182,7 +1182,7 @@ impl BitvSet {
1182
1182
}
1183
1183
1184
1184
#[ inline]
1185
- fn other_op ( & mut self , other : & BitvSet , f : | u32 , u32| -> u32) {
1185
+ fn other_op < F > ( & mut self , other : & BitvSet , mut f : F ) where F : FnMut ( u32 , u32 ) -> u32 {
1186
1186
// Expand the vector if necessary
1187
1187
self . reserve ( other. capacity ( ) ) ;
1188
1188
@@ -1277,10 +1277,12 @@ impl BitvSet {
1277
1277
#[ inline]
1278
1278
#[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1279
1279
pub fn union < ' a > ( & ' a self , other : & ' a BitvSet ) -> TwoBitPositions < ' a > {
1280
+ fn or ( w1 : u32 , w2 : u32 ) -> u32 { w1 | w2 }
1281
+
1280
1282
TwoBitPositions {
1281
1283
set : self ,
1282
1284
other : other,
1283
- merge : |w1 , w2| w1 | w2 ,
1285
+ merge : or ,
1284
1286
current_word : 0u32 ,
1285
1287
next_idx : 0 u
1286
1288
}
@@ -1306,11 +1308,13 @@ impl BitvSet {
1306
1308
#[ inline]
1307
1309
#[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1308
1310
pub fn intersection < ' a > ( & ' a self , other : & ' a BitvSet ) -> Take < TwoBitPositions < ' a > > {
1311
+ fn bitand ( w1 : u32 , w2 : u32 ) -> u32 { w1 & w2 }
1312
+
1309
1313
let min = cmp:: min ( self . capacity ( ) , other. capacity ( ) ) ;
1310
1314
TwoBitPositions {
1311
1315
set : self ,
1312
1316
other : other,
1313
- merge : |w1 , w2| w1 & w2 ,
1317
+ merge : bitand ,
1314
1318
current_word : 0u32 ,
1315
1319
next_idx : 0
1316
1320
} . take ( min)
@@ -1343,10 +1347,12 @@ impl BitvSet {
1343
1347
#[ inline]
1344
1348
#[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1345
1349
pub fn difference < ' a > ( & ' a self , other : & ' a BitvSet ) -> TwoBitPositions < ' a > {
1350
+ fn diff ( w1 : u32 , w2 : u32 ) -> u32 { w1 & !w2 }
1351
+
1346
1352
TwoBitPositions {
1347
1353
set : self ,
1348
1354
other : other,
1349
- merge : |w1 , w2| w1 & !w2 ,
1355
+ merge : diff ,
1350
1356
current_word : 0u32 ,
1351
1357
next_idx : 0
1352
1358
}
@@ -1373,10 +1379,12 @@ impl BitvSet {
1373
1379
#[ inline]
1374
1380
#[ unstable = "matches collection reform specification, waiting for dust to settle" ]
1375
1381
pub fn symmetric_difference < ' a > ( & ' a self , other : & ' a BitvSet ) -> TwoBitPositions < ' a > {
1382
+ fn bitxor ( w1 : u32 , w2 : u32 ) -> u32 { w1 ^ w2 }
1383
+
1376
1384
TwoBitPositions {
1377
1385
set : self ,
1378
1386
other : other,
1379
- merge : |w1 , w2| w1 ^ w2 ,
1387
+ merge : bitxor ,
1380
1388
current_word : 0u32 ,
1381
1389
next_idx : 0
1382
1390
}
@@ -1614,7 +1622,7 @@ pub struct BitPositions<'a> {
1614
1622
pub struct TwoBitPositions < ' a > {
1615
1623
set : & ' a BitvSet ,
1616
1624
other : & ' a BitvSet ,
1617
- merge : | u32 , u32 | : ' a -> u32 ,
1625
+ merge : fn ( u32 , u32 ) -> u32 ,
1618
1626
current_word : u32 ,
1619
1627
next_idx : uint
1620
1628
}
0 commit comments