From 5e50394ba6ca43ef3ba92d1cdf0cee2bc13e0794 Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Thu, 11 Jan 2024 17:35:23 -0600 Subject: [PATCH] chore: clippy cleanups --- .../base_extentions/qr_formatinformation.rs | 3 +-- .../cpp_essentials/base_extentions/qrcode_version.rs | 10 +++++----- src/qrcode/cpp_port/decoder.rs | 2 -- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/common/cpp_essentials/base_extentions/qr_formatinformation.rs b/src/common/cpp_essentials/base_extentions/qr_formatinformation.rs index 143db83..a212329 100644 --- a/src/common/cpp_essentials/base_extentions/qr_formatinformation.rs +++ b/src/common/cpp_essentials/base_extentions/qr_formatinformation.rs @@ -1,8 +1,7 @@ use crate::qrcode::{ cpp_port::Type, decoder::{ - ErrorCorrectionLevel, FormatInformation, FORMAT_INFO_DECODE_LOOKUP, - FORMAT_INFO_MASK_MODEL2, FORMAT_INFO_MASK_QR, + ErrorCorrectionLevel, FormatInformation, FORMAT_INFO_MASK_MODEL2, FORMAT_INFO_MASK_QR, }, }; diff --git a/src/common/cpp_essentials/base_extentions/qrcode_version.rs b/src/common/cpp_essentials/base_extentions/qrcode_version.rs index ca63868..ab779bd 100644 --- a/src/common/cpp_essentials/base_extentions/qrcode_version.rs +++ b/src/common/cpp_essentials/base_extentions/qrcode_version.rs @@ -14,7 +14,7 @@ use crate::Exceptions; impl Version { pub fn Model1(version_number: u32) -> Result { - if version_number < 1 || version_number > 14 { + if !(1..=14).contains(&version_number) { Err(Exceptions::ILLEGAL_ARGUMENT) } else { Ok(&MODEL1_VERSIONS[version_number as usize - 1]) @@ -22,7 +22,7 @@ impl Version { } pub fn Model2(version_number: u32) -> Result { - if version_number < 1 || version_number > 40 { + if !(1..=40).contains(&version_number) { Err(Exceptions::ILLEGAL_ARGUMENT) } else { Ok(&VERSIONS[version_number as usize - 1]) @@ -30,7 +30,7 @@ impl Version { } pub fn Micro(version_number: u32) -> Result { - if version_number < 1 || version_number > 4 { + if !(1..=4).contains(&version_number) { Err(Exceptions::ILLEGAL_ARGUMENT) } else { Ok(&MICRO_VERSIONS[version_number as usize - 1]) @@ -95,12 +95,12 @@ impl Version { pub fn HasMicroSize(bitMatrix: &BitMatrix) -> bool { let size = bitMatrix.height(); - size >= 11 && size <= 17 && (size % 2) == 1 + (11..=17).contains(&size) && (size % 2) == 1 } pub fn HasValidSize(bitMatrix: &BitMatrix) -> bool { let size = bitMatrix.height(); - Self::HasMicroSize(bitMatrix) || (size >= 21 && size <= 177 && (size % 4) == 1) + Self::HasMicroSize(bitMatrix) || ((21..=177).contains(&size) && (size % 4) == 1) } pub fn Number(bitMatrix: &BitMatrix) -> u32 { diff --git a/src/qrcode/cpp_port/decoder.rs b/src/qrcode/cpp_port/decoder.rs index 8b60af5..f9b3c84 100644 --- a/src/qrcode/cpp_port/decoder.rs +++ b/src/qrcode/cpp_port/decoder.rs @@ -17,8 +17,6 @@ use crate::qrcode::cpp_port::bitmatrix_parser::{ use crate::qrcode::decoder::{DataBlock, ErrorCorrectionLevel, Mode, Version}; use crate::Exceptions; -use super::Type; - /** *

Given data and error-correction codewords received, possibly corrupted by errors, attempts to * correct the errors in-place using Reed-Solomon error correction.