Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/sym/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ impl SymbolicBitVec {
}

pub fn into_bytes(self) -> Vec<SymbolicByte> {
assert_eq!(self.bits.len() % 8, 0);
assert!(self.bits.len().is_multiple_of(8));
let num_bytes = self.bits.len() / 8;

let mut bits = [FALSE; 8];
let mut bytes = Vec::with_capacity(num_bytes);

for (i, bit) in self.bits.into_iter().enumerate() {
bits[i % 8] = bit;
if (i + 1) % 8 == 0 {
if (i + 1).is_multiple_of(8) {
bytes.push(bits.into());
bits = [FALSE; 8];
}
Expand All @@ -72,7 +72,7 @@ impl SymbolicBitVec {
}

pub fn into_parts(self, num_bits: usize) -> Vec<Self> {
assert_eq!(self.bits.len() % num_bits, 0);
assert!(self.bits.len().is_multiple_of(8));
let mut parts = Vec::new();
let mut remainder = self;
while remainder.len() > num_bits {
Expand Down
2 changes: 1 addition & 1 deletion crates/sym/src/vec/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ impl TryInto<Vec<SymbolicByte>> for SymbolicBitVec {
type Error = String;

fn try_into(self) -> Result<Vec<SymbolicByte>, Self::Error> {
if self.bits.len() % 8 == 0 {
if self.bits.len().is_multiple_of(8) {
Ok(self.into_bytes())
} else {
Err(format!(
Expand Down