mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
updated cargo fmt
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user