Skip to content

Commit 8f194de

Browse files
cuviperGankra
authored andcommitted
bitv: correct build failures
- Fix typos on Blocks and MutBlocks. - Use slice_to_mut() for creating blocks_mut(). - Deref the block parameter in get(). - Access nbits separately from mutating set in pop().
1 parent 9c51015 commit 8f194de

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/libcollections/bit.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ use std::hash;
8787

8888
use vec::Vec;
8989

90-
type Blocks<'a> = Cloned<Items<'a, u32>>
91-
type MutBlocks<'a> MutItems<'a, u32>;
90+
type Blocks<'a> = Cloned<Items<'a, u32>>;
91+
type MutBlocks<'a> = MutItems<'a, u32>;
9292
type MatchWords<'a> = Chain<Enumerate<Blocks<'a>>, Skip<Take<Enumerate<Repeat<u32>>>>>;
9393

9494
// Take two BitV's, and return iterators of their words, where the shorter one
@@ -199,7 +199,7 @@ impl Bitv {
199199
/// Iterator over mutable refs to the underlying blocks of data.
200200
fn blocks_mut(&mut self) -> MutBlocks {
201201
let blocks = blocks_for_bits(self.len());
202-
self.storage[..blocks].iter_mut()
202+
self.storage.slice_to_mut(blocks).iter_mut()
203203
}
204204

205205
/// Iterator over the underlying blocks of data
@@ -336,7 +336,7 @@ impl Bitv {
336336
assert!(i < self.nbits);
337337
let w = i / u32::BITS;
338338
let b = i % u32::BITS;
339-
self.storage.get(w).map(|block|
339+
self.storage.get(w).map(|&block|
340340
(block & (1 << b)) != 0
341341
)
342342
}
@@ -835,10 +835,11 @@ impl Bitv {
835835
if self.is_empty() {
836836
None
837837
} else {
838-
let ret = self[self.nbits - 1];
838+
let i = self.nbits - 1;
839+
let ret = self[i];
839840
// Second rule of Bitv Club
840-
self.set(self.nbits - 1, false);
841-
self.nbits -= 1;
841+
self.set(i, false);
842+
self.nbits = i;
842843
Some(ret)
843844
}
844845
}

0 commit comments

Comments
 (0)