Skip to content

Commit 80cd485

Browse files
committed
auto merge of #4784 : alexcrichton/rust/bitv-clear-fix, r=graydon
I think that the inversion of `op(&mut w)` may have just been a mistake?
2 parents 5281709 + 406a73f commit 80cd485

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/libstd/bitv.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl BigBitv {
156156
fn each_storage(op: fn(v: &mut uint) -> bool) {
157157
for uint::range(0, self.storage.len()) |i| {
158158
let mut w = self.storage[i];
159-
let b = !op(&mut w);
159+
let b = op(&mut w);
160160
self.storage[i] = w;
161161
if !b { break; }
162162
}
@@ -981,6 +981,24 @@ mod tests {
981981
assert !b1[40];
982982
assert !b1[80];
983983
}
984+
985+
#[test]
986+
pub fn test_small_clear() {
987+
let b = Bitv(14, true);
988+
b.clear();
989+
for b.ones |i| {
990+
die!(fmt!("found 1 at %?", i));
991+
}
992+
}
993+
994+
#[test]
995+
pub fn test_big_clear() {
996+
let b = Bitv(140, true);
997+
b.clear();
998+
for b.ones |i| {
999+
die!(fmt!("found 1 at %?", i));
1000+
}
1001+
}
9841002
}
9851003

9861004
//

0 commit comments

Comments
 (0)