From 406a73fde27ac2352789ced88dad7e72e0e0d2e9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 4 Feb 2013 11:14:33 -0500 Subject: [PATCH] Fix the each_storage() iterator on big bit vectors --- src/libstd/bitv.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 0ad9d0af2ac..df0b36da77c 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -156,7 +156,7 @@ impl BigBitv { fn each_storage(op: fn(v: &mut uint) -> bool) { for uint::range(0, self.storage.len()) |i| { let mut w = self.storage[i]; - let b = !op(&mut w); + let b = op(&mut w); self.storage[i] = w; if !b { break; } } @@ -981,6 +981,24 @@ mod tests { assert !b1[40]; assert !b1[80]; } + + #[test] + pub fn test_small_clear() { + let b = Bitv(14, true); + b.clear(); + for b.ones |i| { + die!(fmt!("found 1 at %?", i)); + } + } + + #[test] + pub fn test_big_clear() { + let b = Bitv(140, true); + b.clear(); + for b.ones |i| { + die!(fmt!("found 1 at %?", i)); + } + } } //