fix potential unwrap on none

This commit is contained in:
Henry Schimke
2023-01-06 10:56:00 -06:00
parent 7996f42c64
commit 6d41475786
5 changed files with 24 additions and 19 deletions

View File

@@ -19,8 +19,8 @@ use std::collections::HashMap;
use crate::{
common::BitArray,
oned::{one_d_reader, OneDReader},
BarcodeFormat, DecodeHintType, DecodingHintDictionary, Exceptions, RXingResult,
RXingResultMetadataType, RXingResultMetadataValue, Reader, DecodeHintValue, RXingResultPoint,
BarcodeFormat, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
RXingResult, RXingResultMetadataType, RXingResultMetadataValue, RXingResultPoint, Reader,
};
use super::{
@@ -263,14 +263,16 @@ impl RSS14Reader {
let startEnd = self.findFinderPattern(row, right)?;
let pattern = self.parseFoundFinderPattern(row, rowNumber, right, &startEnd)?;
if let Some(DecodeHintValue::NeedResultPointCallback(cb)) = hints.get(&DecodeHintType::NEED_RESULT_POINT_CALLBACK) {
if let Some(DecodeHintValue::NeedResultPointCallback(cb)) =
hints.get(&DecodeHintType::NEED_RESULT_POINT_CALLBACK)
{
let startEnd = pattern.getStartEnd();
let mut center :f32 = (startEnd[0] + startEnd[1] - 1) as f32 / 2.0;
let mut center: f32 = (startEnd[0] + startEnd[1] - 1) as f32 / 2.0;
if right {
// row is actually reversed
center = row.getSize() as f32 - 1.0 - center;
// row is actually reversed
center = row.getSize() as f32 - 1.0 - center;
}
cb( &RXingResultPoint::new(center, rowNumber as f32));
cb(&RXingResultPoint::new(center, rowNumber as f32));
}
let outside = self.decodeDataCharacter(row, &pattern, true)?;