Skip to content

Commit 5ccd299

Browse files
committed
fix a logic bug in small_bitv.set
1 parent 9423302 commit 5ccd299

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/libstd/bitv.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct small_bitv {
6161
self.bits |= 1<<i;
6262
}
6363
else {
64-
self.bits &= !(i as u32);
64+
self.bits &= !(1<<i as u32);
6565
}
6666
}
6767
#[inline(always)]
@@ -456,6 +456,14 @@ mod tests {
456456
assert act.eq_vec(~[1u]);
457457
}
458458

459+
#[test]
460+
fn test_2_elements() {
461+
let b = bitv::bitv(2, false);
462+
b.set(0, true);
463+
b.set(1, false);
464+
assert b.to_str() == ~"10";
465+
}
466+
459467
#[test]
460468
fn test_10_elements() {
461469
let mut act;

0 commit comments

Comments
 (0)