From 84a54d420d994edd403e5a12b554c09e40f177e2 Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Thu, 28 Dec 2023 16:29:13 -0600 Subject: [PATCH] chore: various cleanups, version bump 0.4.12 --- Cargo.toml | 2 +- src/client/result/VCardResultParser.rs | 6 +++--- src/client/result/VEventResultParser.rs | 2 +- src/common/minimal_eci_input.rs | 2 +- src/common/reedsolomon/mod.rs | 2 +- src/oned/code_39_reader.rs | 2 +- src/oned/code_93_reader.rs | 2 +- src/oned/rss/expanded/bit_array_builder.rs | 2 +- src/oned/rss/expanded/rss_expanded_reader.rs | 4 ++-- src/qrcode/cpp_port/bitmatrix_parser.rs | 6 ++---- src/qrcode/detector/alignment_pattern_finder.rs | 2 +- src/qrcode/encoder/minimal_encoder.rs | 4 ++-- 12 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d2da97a7..97453101 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rxing" -version = "0.4.11" +version = "0.4.12" description="A rust port of the zxing barcode library." license="Apache-2.0" repository="https://github.com/rxing-core/rxing" diff --git a/src/client/result/VCardResultParser.rs b/src/client/result/VCardResultParser.rs index ce66f7cf..b5e4e9ce 100644 --- a/src/client/result/VCardResultParser.rs +++ b/src/client/result/VCardResultParser.rs @@ -428,7 +428,7 @@ pub fn matchSingleVCardPrefixedField( if values.is_empty() { return None; } - Some(values.get(0)?.clone()) + Some(values.first()?.clone()) // return values == null || values.isEmpty() ? null : values.get(0); } @@ -437,7 +437,7 @@ fn toPrimaryValue(list: Option>) -> String { if l.is_empty() { String::default() } else { - l.get(0).unwrap_or(&String::default()).clone() + l.first().unwrap_or(&String::default()).clone() } } else { String::default() @@ -471,7 +471,7 @@ fn toTypes(lists: Option>>) -> Vec { let mut result = Vec::with_capacity(local_lists.len()); //new ArrayList<>(lists.size()); for list in local_lists { // for (List list : lists) { - if let Some(value) = list.get(0) { + if let Some(value) = list.first() { if !value.is_empty() { let mut v_type = String::new(); let final_value = list.last().unwrap_or(&String::default()).clone(); diff --git a/src/client/result/VEventResultParser.rs b/src/client/result/VEventResultParser.rs index ab795742..9c97ef89 100644 --- a/src/client/result/VEventResultParser.rs +++ b/src/client/result/VEventResultParser.rs @@ -152,7 +152,7 @@ fn matchVCardPrefixedField(prefix: &str, rawText: &str) -> Vec { for (i, res) in result.iter_mut().enumerate().take(size) { // for i in 0..size { // for (int i = 0; i < size; i++) { - *res = values.get(i).unwrap().get(0).unwrap().clone(); + *res = values.get(i).unwrap().first().unwrap().clone(); } result } diff --git a/src/common/minimal_eci_input.rs b/src/common/minimal_eci_input.rs index 80619a32..388425bc 100644 --- a/src/common/minimal_eci_input.rs +++ b/src/common/minimal_eci_input.rs @@ -404,7 +404,7 @@ struct InputEdge { cachedTotalSize: usize, } impl InputEdge { - const FNC1_UNICODE: &str = "\u{1000}"; + const FNC1_UNICODE: &'static str = "\u{1000}"; pub fn new( c: &str, diff --git a/src/common/reedsolomon/mod.rs b/src/common/reedsolomon/mod.rs index c675bf80..1ba3dba3 100644 --- a/src/common/reedsolomon/mod.rs +++ b/src/common/reedsolomon/mod.rs @@ -63,7 +63,7 @@ pub fn get_predefined_genericgf(request: PredefinedGenericGF) -> GenericGFRef { PredefinedGenericGF::DataMatrixField256 | PredefinedGenericGF::AztecData8 => { &DATA_MATRIX_FIELD_256 } // x^8 + x^5 + x^3 + x^2 + 1 - // PredefinedGenericGF::PDF417 => &PDF_417_FIELD, + // PredefinedGenericGF::PDF417 => &PDF_417_FIELD, } } diff --git a/src/oned/code_39_reader.rs b/src/oned/code_39_reader.rs index 7a518706..21935d66 100644 --- a/src/oned/code_39_reader.rs +++ b/src/oned/code_39_reader.rs @@ -149,7 +149,7 @@ impl OneDReader for Code39Reader { } } impl Code39Reader { - pub const ALPHABET_STRING: &str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; + pub const ALPHABET_STRING: &'static str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; /** * These represent the encodings of characters, as patterns of wide and narrow bars. diff --git a/src/oned/code_93_reader.rs b/src/oned/code_93_reader.rs index 5c6e5a8b..72f4ec92 100644 --- a/src/oned/code_93_reader.rs +++ b/src/oned/code_93_reader.rs @@ -134,7 +134,7 @@ impl OneDReader for Code93Reader { impl Code93Reader { // Note that 'abcd' are dummy characters in place of control characters. - pub const ALPHABET_STRING: &str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*"; + pub const ALPHABET_STRING: &'static str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*"; pub const ALPHABET: [char; 48] = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', diff --git a/src/oned/rss/expanded/bit_array_builder.rs b/src/oned/rss/expanded/bit_array_builder.rs index 8c964748..210d6066 100644 --- a/src/oned/rss/expanded/bit_array_builder.rs +++ b/src/oned/rss/expanded/bit_array_builder.rs @@ -49,7 +49,7 @@ pub fn buildBitArray(pairs: &Vec) -> Option { let mut binary = BitArray::with_size(size); let mut accPos = 0; - let firstPair = pairs.get(0)?; + let firstPair = pairs.first()?; let rp = firstPair.getRightChar().as_ref()?; let firstValue = rp.getValue(); let mut i = 11; diff --git a/src/oned/rss/expanded/rss_expanded_reader.rs b/src/oned/rss/expanded/rss_expanded_reader.rs index 1f49325f..f9f2eeec 100644 --- a/src/oned/rss/expanded/rss_expanded_reader.rs +++ b/src/oned/rss/expanded/rss_expanded_reader.rs @@ -535,7 +535,7 @@ impl RSSExpandedReader { let resultingString = decoder.parseInformation()?; let firstPoints = pairs - .get(0) + .first() .ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)? .getFinderPattern() .as_ref() @@ -565,7 +565,7 @@ impl RSSExpandedReader { } fn checkChecksum(&self) -> bool { - let Some(firstPair) = self.pairs.get(0) else { + let Some(firstPair) = self.pairs.first() else { return false; }; let checkCharacter = firstPair.getLeftChar(); diff --git a/src/qrcode/cpp_port/bitmatrix_parser.rs b/src/qrcode/cpp_port/bitmatrix_parser.rs index dc6e270e..58a92bc1 100644 --- a/src/qrcode/cpp_port/bitmatrix_parser.rs +++ b/src/qrcode/cpp_port/bitmatrix_parser.rs @@ -123,8 +123,7 @@ pub fn ReadQRCodewords( ) -> Result> { let functionPattern: BitMatrix = version.buildFunctionPattern()?; - let mut result = Vec::new(); - result.reserve(version.getTotalCodewords() as usize); + let mut result = Vec::with_capacity(version.getTotalCodewords() as usize); let mut currentByte = 0; let mut readingUp = true; let mut bitsRead = 0; @@ -190,8 +189,7 @@ pub fn ReadMQRCodewords( 9 }; - let mut result = Vec::new(); - result.reserve(version.getTotalCodewords() as usize); + let mut result = Vec::with_capacity(version.getTotalCodewords() as usize); let mut currentByte = 0; let mut readingUp = true; let mut bitsRead = 0; diff --git a/src/qrcode/detector/alignment_pattern_finder.rs b/src/qrcode/detector/alignment_pattern_finder.rs index 5b252c7e..ac1b0f00 100644 --- a/src/qrcode/detector/alignment_pattern_finder.rs +++ b/src/qrcode/detector/alignment_pattern_finder.rs @@ -163,7 +163,7 @@ impl AlignmentPatternFinder { if !self.possibleCenters.is_empty() { Ok(*(self .possibleCenters - .get(0) + .first() .ok_or(Exceptions::INDEX_OUT_OF_BOUNDS))?) } else { Err(Exceptions::NOT_FOUND) diff --git a/src/qrcode/encoder/minimal_encoder.rs b/src/qrcode/encoder/minimal_encoder.rs index ffda8fc1..651c8178 100644 --- a/src/qrcode/encoder/minimal_encoder.rs +++ b/src/qrcode/encoder/minimal_encoder.rs @@ -754,7 +754,7 @@ impl RXingResultList { // prepend FNC1 if needed. If the bits contain an ECI then the FNC1 must be preceeded by an ECI. // If there is no ECI at the beginning then we put an ECI to the default charset (ISO-8859-1) if isGS1 { - if let Some(first) = list.get(0) { + if let Some(first) = list.first() { if first.mode != Mode::ECI && containsECI { // prepend a default character set ECI list.push(RXingResultNode::new( @@ -769,7 +769,7 @@ impl RXingResultList { } } - if let Some(first) = list.get(0) { + if let Some(first) = list.first() { // prepend or insert a FNC1_FIRST_POSITION after the ECI (if any) if first.mode != Mode::ECI { //&& containsECI {