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

@@ -58,8 +58,7 @@ impl EANManufacturerOrgSupport {
return Some( return Some(
self.countryIdentifiers self.countryIdentifiers
.get(i) .get(i)
.expect("must have index i or fail") .expect("must have index i or fail"), // .clone(),
// .clone(),
); );
} }
} }

View File

@@ -19,8 +19,8 @@ use std::collections::HashMap;
use crate::{ use crate::{
common::BitArray, common::BitArray,
oned::{one_d_reader, OneDReader}, oned::{one_d_reader, OneDReader},
BarcodeFormat, DecodeHintType, DecodingHintDictionary, Exceptions, RXingResult, BarcodeFormat, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
RXingResultMetadataType, RXingResultMetadataValue, Reader, DecodeHintValue, RXingResultPoint, RXingResult, RXingResultMetadataType, RXingResultMetadataValue, RXingResultPoint, Reader,
}; };
use super::{ use super::{
@@ -263,7 +263,9 @@ impl RSS14Reader {
let startEnd = self.findFinderPattern(row, right)?; let startEnd = self.findFinderPattern(row, right)?;
let pattern = self.parseFoundFinderPattern(row, rowNumber, right, &startEnd)?; 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 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 { if right {

View File

@@ -309,6 +309,10 @@ fn getBarcodeMetadata<T: DetectionRXingResultRowIndicatorColumn>(
// return leftBarcodeMetadata; // return leftBarcodeMetadata;
// } // }
if leftBarcodeMetadata.is_none() {
return None;
}
if leftBarcodeMetadata.as_ref().unwrap().getColumnCount() if leftBarcodeMetadata.as_ref().unwrap().getColumnCount()
!= rightBarcodeMetadata.as_ref().unwrap().getColumnCount() != rightBarcodeMetadata.as_ref().unwrap().getColumnCount()
&& leftBarcodeMetadata && leftBarcodeMetadata