1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use super::BitsMut;
use storage::BlockType;
pub trait BitsPush: BitsMut {
fn push_bit(&mut self, value: bool);
fn pop_bit(&mut self) -> Option<bool>;
fn align_block(&mut self, value: bool) {
while Self::Block::mod_nbits(self.bit_len()) != 0 {
self.push_bit(value);
}
}
fn push_block(&mut self, mut value: Self::Block) {
self.align_block(false);
for _ in 0 .. Self::Block::nbits() {
self.push_bit(value & Self::Block::one() != Self::Block::zero());
value = value >> 1;
}
}
}
impl BitsPush for Vec<bool> {
fn push_bit(&mut self, value: bool) {
self.push(value);
}
fn pop_bit(&mut self) -> Option<bool> {
self.pop()
}
}