rename helper methods

This commit is contained in:
Vukašin Stepanović
2023-02-15 12:52:59 +00:00
parent bfcdb397ad
commit 935519ced5
133 changed files with 858 additions and 1044 deletions

View File

@@ -49,10 +49,8 @@ impl UPCEANReader for UPCEReader {
let mut x = 0;
while x < 6 && rowOffset < end {
let bestMatch = self.decodeDigit(row, &mut counters, rowOffset, &L_AND_G_PATTERNS)?;
resultString.push(
char::from_u32('0' as u32 + bestMatch as u32 % 10)
.ok_or(Exceptions::parseEmpty())?,
);
resultString
.push(char::from_u32('0' as u32 + bestMatch as u32 % 10).ok_or(Exceptions::parse)?);
rowOffset += counters.iter().sum::<u32>() as usize;
if bestMatch >= 10 {
@@ -68,9 +66,7 @@ impl UPCEANReader for UPCEReader {
}
fn checkChecksum(&self, s: &str) -> Result<bool, Exceptions> {
self.checkStandardUPCEANChecksum(
&convertUPCEtoUPCA(s).ok_or(Exceptions::illegalArgumentEmpty())?,
)
self.checkStandardUPCEANChecksum(&convertUPCEtoUPCA(s).ok_or(Exceptions::illegalArgument)?)
}
fn decodeEnd(
@@ -132,17 +128,15 @@ impl UPCEReader {
if lgPatternFound == Self::NUMSYS_AND_CHECK_DIGIT_PATTERNS[numSys][d] {
resultString.insert(
0,
char::from_u32('0' as u32 + numSys as u32)
.ok_or(Exceptions::parseEmpty())?,
);
resultString.push(
char::from_u32('0' as u32 + d as u32).ok_or(Exceptions::parseEmpty())?,
char::from_u32('0' as u32 + numSys as u32).ok_or(Exceptions::parse)?,
);
resultString
.push(char::from_u32('0' as u32 + d as u32).ok_or(Exceptions::parse)?);
return Ok(());
}
}
}
Err(Exceptions::notFoundEmpty())
Err(Exceptions::notFound)
}
}