]> git.lizzy.rs Git - rust.git/commit
bitv: Fix all() for nbits that are multiples of u32::BITS
authorJosh Stone <cuviper@gmail.com>
Wed, 10 Dec 2014 06:06:52 +0000 (22:06 -0800)
committerAlexis Beingessner <a.beingessner@gmail.com>
Sat, 20 Dec 2014 14:10:04 +0000 (09:10 -0500)
commit3deb97f5d02ddbdbf20a587815fe84934cda948c
treeb74e83efd28a5a494e7d272aaddef319fd9e79dc
parent8f194de95d00fe540d848cc9a7d3e049ce3684ab
bitv: Fix all() for nbits that are multiples of u32::BITS

The old logic would be ok with *either* 0 or all 1s in the last word,
because it didn't compute a proper mask for the case where nbits is an
exact multiple of u32::BITS.

Add mask_for_bits() to compute this properly, and use it in all().  Add
all/none assertions to most of the tests.  Note in particular, the all-zero
bitv in test_32_elements() was incorrectly all()==true before this patch.
src/libcollections/bit.rs