Skip to content

Commit f1ecf92

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 163775 b: refs/heads/master c: 0055678 h: refs/heads/master i: 163773: 0febdaf 163771: b5e5d20 163767: 15c88db 163759: 4fd75e5 163743: 5e4f329 163711: baedd05 v: v3
1 parent 7cae944 commit f1ecf92

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 0d39fc01bf2b105abd323a8f8ebd59b60f2790e7
2+
refs/heads/master: 0055678f7a5f49fc5df93a38cc27fea4eb6ae416
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 8443b09e361b96d1f9b7f45a65ed0d31c0e86e70
55
refs/heads/try: 20cbbffeefc1f35e2ea63afce7b42fbd79611d42

trunk/src/libcollections/bit.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'a> Iterator<(uint, u32)> for MaskWords<'a> {
174174

175175
impl Bitv {
176176
#[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 {
178178
let len = other.storage.len();
179179
assert_eq!(self.storage.len(), len);
180180
let mut changed = false;
@@ -816,7 +816,7 @@ pub fn from_bytes(bytes: &[u8]) -> Bitv {
816816
/// let bv = from_fn(5, |i| { i % 2 == 0 });
817817
/// assert!(bv.eq_vec(&[true, false, true, false, true]));
818818
/// ```
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 {
820820
let mut bitv = Bitv::with_capacity(len, false);
821821
for i in range(0u, len) {
822822
bitv.set(i, f(i));
@@ -1182,7 +1182,7 @@ impl BitvSet {
11821182
}
11831183

11841184
#[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 {
11861186
// Expand the vector if necessary
11871187
self.reserve(other.capacity());
11881188

@@ -1277,10 +1277,12 @@ impl BitvSet {
12771277
#[inline]
12781278
#[unstable = "matches collection reform specification, waiting for dust to settle"]
12791279
pub fn union<'a>(&'a self, other: &'a BitvSet) -> TwoBitPositions<'a> {
1280+
fn or(w1: u32, w2: u32) -> u32 { w1 | w2 }
1281+
12801282
TwoBitPositions {
12811283
set: self,
12821284
other: other,
1283-
merge: |w1, w2| w1 | w2,
1285+
merge: or,
12841286
current_word: 0u32,
12851287
next_idx: 0u
12861288
}
@@ -1306,11 +1308,13 @@ impl BitvSet {
13061308
#[inline]
13071309
#[unstable = "matches collection reform specification, waiting for dust to settle"]
13081310
pub fn intersection<'a>(&'a self, other: &'a BitvSet) -> Take<TwoBitPositions<'a>> {
1311+
fn bitand(w1: u32, w2: u32) -> u32 { w1 & w2 }
1312+
13091313
let min = cmp::min(self.capacity(), other.capacity());
13101314
TwoBitPositions {
13111315
set: self,
13121316
other: other,
1313-
merge: |w1, w2| w1 & w2,
1317+
merge: bitand,
13141318
current_word: 0u32,
13151319
next_idx: 0
13161320
}.take(min)
@@ -1343,10 +1347,12 @@ impl BitvSet {
13431347
#[inline]
13441348
#[unstable = "matches collection reform specification, waiting for dust to settle"]
13451349
pub fn difference<'a>(&'a self, other: &'a BitvSet) -> TwoBitPositions<'a> {
1350+
fn diff(w1: u32, w2: u32) -> u32 { w1 & !w2 }
1351+
13461352
TwoBitPositions {
13471353
set: self,
13481354
other: other,
1349-
merge: |w1, w2| w1 & !w2,
1355+
merge: diff,
13501356
current_word: 0u32,
13511357
next_idx: 0
13521358
}
@@ -1373,10 +1379,12 @@ impl BitvSet {
13731379
#[inline]
13741380
#[unstable = "matches collection reform specification, waiting for dust to settle"]
13751381
pub fn symmetric_difference<'a>(&'a self, other: &'a BitvSet) -> TwoBitPositions<'a> {
1382+
fn bitxor(w1: u32, w2: u32) -> u32 { w1 ^ w2 }
1383+
13761384
TwoBitPositions {
13771385
set: self,
13781386
other: other,
1379-
merge: |w1, w2| w1 ^ w2,
1387+
merge: bitxor,
13801388
current_word: 0u32,
13811389
next_idx: 0
13821390
}
@@ -1614,7 +1622,7 @@ pub struct BitPositions<'a> {
16141622
pub struct TwoBitPositions<'a> {
16151623
set: &'a BitvSet,
16161624
other: &'a BitvSet,
1617-
merge: |u32, u32|: 'a -> u32,
1625+
merge: fn(u32, u32) -> u32,
16181626
current_word: u32,
16191627
next_idx: uint
16201628
}

0 commit comments

Comments
 (0)