Skip to content

Commit a5e921d

Browse files
committed
Merge pull request #2457 from bkircher/2363-bitv-each-loops-forever
std: Fix bitv each() method (issue 2363)
2 parents 2c90d66 + 360194d commit a5e921d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/bitv.rs

+10
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ fn each(v: bitv, f: fn(bool) -> bool) {
197197
let mut i = 0u;
198198
while i < v.nbits {
199199
if !f(get(v, i)) { break; }
200+
i = i + 1u;
200201
}
201202
}
202203

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

234235
#[cfg(test)]
235236
mod tests {
237+
#[test]
238+
fn test_to_str() {
239+
let zerolen = bitv(0u, false);
240+
assert to_str(zerolen) == "";
241+
242+
let eightbits = bitv(8u, false);
243+
assert to_str(eightbits) == "00000000";
244+
}
245+
236246
#[test]
237247
fn test_0_elements() {
238248
let mut act;

0 commit comments

Comments
 (0)