updated cargo fmt

This commit is contained in:
Henry Schimke
2023-10-28 11:04:14 -05:00
parent 4c9ec95d00
commit 5ea03cc066
24 changed files with 122 additions and 64 deletions

View File

@@ -108,7 +108,11 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32> {
// Check for forced code set hint.
let mut forcedCodeSet = -1_i32;
if hints.contains_key(&EncodeHintType::FORCE_CODE_SET) {
let Some(EncodeHintValue::ForceCodeSet(codeSetHint)) = hints.get(&EncodeHintType::FORCE_CODE_SET) else { return Err(Exceptions::ILLEGAL_STATE) };
let Some(EncodeHintValue::ForceCodeSet(codeSetHint)) =
hints.get(&EncodeHintType::FORCE_CODE_SET)
else {
return Err(Exceptions::ILLEGAL_STATE);
};
match codeSetHint.as_str() {
"A" => forcedCodeSet = CODE_CODE_A as i32,
"B" => forcedCodeSet = CODE_CODE_B as i32,

View File

@@ -71,8 +71,13 @@ impl OneDimensionalCodeWriter for Code39Writer {
pos += Self::appendPattern(&mut result, pos as usize, &narrowWhite, false);
//append next character to byte matrix
for i in 0..length {
let Some(indexInString) = Code39Reader::ALPHABET_STRING.find(contents.chars().nth(i).ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?) else {
continue;
let Some(indexInString) = Code39Reader::ALPHABET_STRING.find(
contents
.chars()
.nth(i)
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?,
) else {
continue;
};
Self::toIntArray(
Code39Reader::CHARACTER_ENCODINGS[indexInString],

View File

@@ -49,7 +49,14 @@ impl OneDimensionalCodeWriter for Code93Writer {
for i in 0..length {
// for (int i = 0; i < length; i++) {
let Some(indexInString) = Code93Reader::ALPHABET_STRING.find(contents.chars().nth(i).ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?) else {panic!("alphabet")};
let Some(indexInString) = Code93Reader::ALPHABET_STRING.find(
contents
.chars()
.nth(i)
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?,
) else {
panic!("alphabet")
};
pos += Self::appendPattern(
&mut result,
pos,
@@ -132,7 +139,11 @@ impl Code93Writer {
for i in (0..contents.chars().count()).rev() {
// for (int i = contents.length() - 1; i >= 0; i--) {
let Some(indexInString) = Code93Reader::ALPHABET_STRING.find(contents.chars().nth(i).unwrap()) else {panic!("not in the alphabet");};
let Some(indexInString) =
Code93Reader::ALPHABET_STRING.find(contents.chars().nth(i).unwrap())
else {
panic!("not in the alphabet");
};
total += indexInString as u32 * weight;
weight += 1;
if weight > maxWeight {

View File

@@ -105,7 +105,7 @@ pub trait OneDReader: Reader {
}
}
let Ok(mut result) = self.decode_row(row_number as u32, &row, &hints) else {
continue
continue;
};
// We found our barcode
if attempt == 1 {

View File

@@ -87,8 +87,10 @@ fn assertCorrectImage2result(fileName: &str, expected: ExpandedProductParsedRXin
theRXingResult.getBarcodeFormat()
);
let ParsedClientResult::ExpandedProductResult(result) = crate::client::result::parseRXingResult(&theRXingResult) else {
panic!("incorrect result type found");
let ParsedClientResult::ExpandedProductResult(result) =
crate::client::result::parseRXingResult(&theRXingResult)
else {
panic!("incorrect result type found");
};
assert_eq!(expected, result);