Skip to content

Commit

Permalink
Merge pull request #2457 from bkircher/2363-bitv-each-loops-forever
Browse files Browse the repository at this point in the history
std: Fix bitv each() method (issue 2363)
  • Loading branch information
pcwalton committed May 28, 2012
2 parents 2c90d66 + 360194d commit a5e921d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libstd/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ fn each(v: bitv, f: fn(bool) -> bool) {
let mut i = 0u;
while i < v.nbits {
if !f(get(v, i)) { break; }
i = i + 1u;
}
}

Expand Down Expand Up @@ -233,6 +234,15 @@ fn eq_vec(v0: bitv, v1: [uint]) -> bool {

#[cfg(test)]
mod tests {
#[test]
fn test_to_str() {
let zerolen = bitv(0u, false);
assert to_str(zerolen) == "";

let eightbits = bitv(8u, false);
assert to_str(eightbits) == "00000000";
}

#[test]
fn test_0_elements() {
let mut act;
Expand Down

0 comments on commit a5e921d

Please sign in to comment.