many small rustifications

This commit is contained in:
Henry Schimke
2023-01-10 14:33:47 -06:00
parent 752d8c87b9
commit 9f7a41f81c
23 changed files with 218 additions and 187 deletions

View File

@@ -158,11 +158,10 @@ fn decode_bitmatrix_parser_with_hints(
let dataBlocks = DataBlock::getDataBlocks(&codewords, version, ecLevel)?;
// Count total number of data bytes
let mut totalBytes = 0usize;
for dataBlock in &dataBlocks {
// for (DataBlock dataBlock : dataBlocks) {
totalBytes += dataBlock.getNumDataCodewords() as usize;
}
let totalBytes = dataBlocks.iter().fold(0, |acc,dataBlock| {
acc + dataBlock.getNumDataCodewords() as usize
});
let mut resultBytes = vec![0u8; totalBytes];
let mut resultOffset = 0;

View File

@@ -686,11 +686,10 @@ impl FinderPatternFinder {
// vary too much. We arbitrarily say that when the total deviation from average exceeds
// 5% of the total module size estimates, it's too much.
let average = totalModuleSize / max as f32;
let mut totalDeviation = 0.0;
for pattern in &self.possibleCenters {
// for (FinderPattern pattern : possibleCenters) {
totalDeviation += (pattern.getEstimatedModuleSize() - average).abs();
}
let totalDeviation = self.possibleCenters.iter().fold(0.0, |acc, pattern| {
acc + (pattern.getEstimatedModuleSize() - average).abs()
});
totalDeviation <= 0.05 * totalModuleSize
}

View File

@@ -529,7 +529,7 @@ pub fn getNumDataBytesAndNumECBytesForBlockID(
+ ((num_data_bytes_in_group2 + numEcBytesInGroup2) * num_rs_blocks_in_group2)
{
return Err(Exceptions::WriterException(Some(
"Total bytes mismatch".to_owned(),
"total bytes mismatch".to_owned(),
)));
// throw new WriterException("Total bytes mismatch");