Update macro and cargo fmt

This commit is contained in:
Steve Cook
2023-03-01 13:43:21 -05:00
parent 51fcc98b34
commit b561bd77c3
19 changed files with 101 additions and 64 deletions

View File

@@ -113,7 +113,8 @@ impl OneDReader for CodaBarReader {
.decodeRowRXingResult
.chars()
.nth(i)
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)? as usize]
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?
as usize]
.to_string(),
);
}

View File

@@ -590,7 +590,8 @@ stuvwxyz{|}~\u{007F}\u{00FF}";
contents
.chars()
.nth(i)
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)? as isize
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?
as isize
- ' ' as isize
}
};

View File

@@ -322,7 +322,10 @@ impl Code39Reader {
while i < length {
// for i in 0..length {
// for (int i = 0; i < length; i++) {
let c = encoded.chars().nth(i).ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?;
let c = encoded
.chars()
.nth(i)
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?;
if c == '+' || c == '$' || c == '%' || c == '/' {
let next = encoded
.chars()

View File

@@ -234,7 +234,10 @@ impl Code93Reader {
while i < length {
// for i in 0..length {
// for (int i = 0; i < length; i++) {
let c = encoded.chars().nth(i).ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?;
let c = encoded
.chars()
.nth(i)
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?;
if ('a'..='d').contains(&c) {
if i >= length - 1 {
return Err(Exceptions::FORMAT);
@@ -334,7 +337,12 @@ impl Code93Reader {
for i in (0..checkPosition).rev() {
total += weight
* Self::ALPHABET_STRING
.find(result.chars().nth(i).ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?)
.find(
result
.chars()
.nth(i)
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?,
)
.map_or_else(|| -1_i32, |v| v as i32);
weight += 1;
if weight > weightMax as i32 {

View File

@@ -528,8 +528,8 @@ impl RSSExpandedReader {
// Not private for unit testing
pub(crate) fn constructRXingResult(pairs: &[ExpandedPair]) -> Result<RXingResult> {
let binary = bit_array_builder::buildBitArray(&pairs.to_vec())
.ok_or(Exceptions::ILLEGAL_STATE)?;
let binary =
bit_array_builder::buildBitArray(&pairs.to_vec()).ok_or(Exceptions::ILLEGAL_STATE)?;
let mut decoder = abstract_expanded_decoder::createDecoder(&binary)?;
let resultingString = decoder.parseInformation()?;
@@ -692,7 +692,9 @@ impl RSSExpandedReader {
} else if previousPairs.is_empty() {
rowOffset = 0;
} else {
let lastPair = previousPairs.last().ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?;
let lastPair = previousPairs
.last()
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?;
rowOffset = lastPair
.getFinderPattern()
.as_ref()

View File

@@ -66,9 +66,7 @@ impl UPCEANReader for UPCEReader {
}
fn checkChecksum(&self, s: &str) -> Result<bool> {
self.checkStandardUPCEANChecksum(
&convertUPCEtoUPCA(s).ok_or(Exceptions::ILLEGAL_ARGUMENT)?,
)
self.checkStandardUPCEANChecksum(&convertUPCEtoUPCA(s).ok_or(Exceptions::ILLEGAL_ARGUMENT)?)
}
fn decodeEnd(&self, row: &crate::common::BitArray, endStart: usize) -> Result<[usize; 2]> {