mozilla/rust — pull request #11615 by Alewhey (2014-01-17 12:26:52+00:00)
Title: Fixed bug when initialising bitv from bool=true

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<