mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
many small rustifications
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user