From 752d8c87b9edc77e3587a65988a440fdec5043e8 Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Tue, 10 Jan 2023 09:55:19 -0600 Subject: [PATCH] fix small clippy issue and bump version --- Cargo.toml | 2 +- src/common/bit_matrix.rs | 6 +--- .../decoder/pdf_417_scanning_decoder.rs | 29 ++++++++++--------- src/qrcode/decoder/decoder.rs | 10 +++++-- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aa951a8..aa3ba9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rxing" -version = "0.2.12" +version = "0.2.13" description="A rust port of the zxing barcode library." license="Apache-2.0" repository="https://github.com/hschimke/rxing" diff --git a/src/common/bit_matrix.rs b/src/common/bit_matrix.rs index fc5bc76..5ad9157 100644 --- a/src/common/bit_matrix.rs +++ b/src/common/bit_matrix.rs @@ -680,11 +680,7 @@ impl From<&BitMatrix> for image::DynamicImage { let pixel_value = if value.get(x, y) { u8::MIN } else { u8::MAX }; let pixel_intrior = [pixel_value, pixel_value, pixel_value]; let pixel = image::Rgb(pixel_intrior); - pixels.put_pixel( - x, - y, - pixel, - ); + pixels.put_pixel(x, y, pixel); } } pixels.into() diff --git a/src/pdf417/decoder/pdf_417_scanning_decoder.rs b/src/pdf417/decoder/pdf_417_scanning_decoder.rs index cf56b38..b4cae71 100644 --- a/src/pdf417/decoder/pdf_417_scanning_decoder.rs +++ b/src/pdf417/decoder/pdf_417_scanning_decoder.rs @@ -616,25 +616,28 @@ fn getStartColumn( while isValidBarcodeColumn(detectionRXingResult, (barcodeColumn - offset) as usize) { barcodeColumn -= offset; - for previousRowCodeword in detectionRXingResult + if let Some(previousRowCodeword) = detectionRXingResult .getDetectionRXingResultColumn(barcodeColumn as usize) .as_ref() .unwrap() .getCodewords() + .iter() + .flatten() + .next() { // for (Codeword previousRowCodeword : detectionRXingResult.getDetectionRXingResultColumn(barcodeColumn).getCodewords()) { - if let Some(previousRowCodeword) = previousRowCodeword { - // if previousRowCodeword.is_some() { - return ((if leftToRight { - previousRowCodeword.getEndX() - } else { - previousRowCodeword.getStartX() - }) as isize - + offset - * skippedColumns as isize - * (previousRowCodeword.getEndX() - previousRowCodeword.getStartX()) - as isize) as u32; - } + // if let Some(previousRowCodeword) = previousRowCodeword { + // if previousRowCodeword.is_some() { + return ((if leftToRight { + previousRowCodeword.getEndX() + } else { + previousRowCodeword.getStartX() + }) as isize + + offset + * skippedColumns as isize + * (previousRowCodeword.getEndX() - previousRowCodeword.getStartX()) as isize) + as u32; + // } } skippedColumns += 1; } diff --git a/src/qrcode/decoder/decoder.rs b/src/qrcode/decoder/decoder.rs index 2931fe1..7b22d02 100644 --- a/src/qrcode/decoder/decoder.rs +++ b/src/qrcode/decoder/decoder.rs @@ -215,9 +215,13 @@ fn correctErrors(codewordBytes: &mut [u8], numDataCodewords: usize) -> Result<() // Copy back into array of bytes -- only need to worry about the bytes that were data // We don't care about errors in the error-correction codewords - for (code_word, sent_code_word ) in codewordBytes.iter_mut().zip(sending_code_words.iter()).take(numDataCodewords){ - *code_word = *sent_code_word as u8; + for (code_word, sent_code_word) in codewordBytes + .iter_mut() + .zip(sending_code_words.iter()) + .take(numDataCodewords) + { + *code_word = *sent_code_word as u8; } - + Ok(()) }