]> git.lizzy.rs Git - rust.git/commitdiff
fix a logic bug in small_bitv.set
authorGareth Daniel Smith <garethdanielsmith@gmail.com>
Tue, 21 Aug 2012 18:41:29 +0000 (19:41 +0100)
committerGareth Daniel Smith <garethdanielsmith@gmail.com>
Tue, 21 Aug 2012 18:41:29 +0000 (19:41 +0100)
src/libstd/bitv.rs

index 77d39616b61c8f06f7c756182a26e9a322253747..91e9a1dc940628dc6bcfc311b70e58723d8ab7c7 100644 (file)
@@ -61,7 +61,7 @@ fn set(i: uint, x: bool) {
             self.bits |= 1<<i;
         }
         else {
-            self.bits &= !(i as u32);
+            self.bits &= !(1<<i as u32);
         }
     }
     #[inline(always)]
@@ -456,6 +456,14 @@ fn test_1_element() {
         assert act.eq_vec(~[1u]);
     }
 
+    #[test]
+    fn test_2_elements() {
+        let b = bitv::bitv(2, false);
+        b.set(0, true);
+        b.set(1, false);
+        assert b.to_str() == ~"10";
+    }
+
     #[test]
     fn test_10_elements() {
         let mut act;