]> git.lizzy.rs Git - rust.git/commit
auto merge of #11615 : adwhit/rust/master, r=cmr
authorbors <bors@rust-lang.org>
Sun, 19 Jan 2014 05:56:34 +0000 (21:56 -0800)
committerbors <bors@rust-lang.org>
Sun, 19 Jan 2014 05:56:34 +0000 (21:56 -0800)
commit6d55211700545d253dec4ebbe386832e00d2a247
tree0dfbc7c07c5fa4b34c6e3e13d342e35331b0f402
parent1a9641bf8e02230427a6e90e6662b879dec8caf2
parent32408a6e32ba396a8e5f4d183d6b80352dfad092
auto merge of #11615 : adwhit/rust/master, r=cmr

This is my first patch so feedback appreciated!

Bug when initialising `bitv:Bitv::new(int,bool)` when `bool=true`. It created a `Bitv` with underlying representation `!0u` rather than the actual desired bit layout ( e.g. `11111111` instead of `00001111`). This works OK because a size attribute is included which keeps access to legal bounds.  However when using `BitvSet::from_bitv(Bitv)`, we then find that `bitvset.contains(i)` can return true when `i` should not in fact be in the set.

```
let bs = BitvSet::from_bitv(Bitv::new(100, true));
assert!(!bs.contains(&127)) //fails
```

The fix is to create the correct representation by treating various cases separately and using a bitshift `(1<<nbits) - 1` to generate correct number of `1`s where necessary.
src/libextra/bitv.rs