From 42d40de755d1ca27ffcb266df32ba27faff0012a Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Fri, 27 Jan 2023 15:24:24 -0600 Subject: [PATCH] cargo clippy --fix --- src/aztec/DecoderTest.rs | 3 +- src/aztec/DetectorTest.rs | 4 +- src/aztec/EncoderTest.rs | 18 +++---- src/aztec/aztec_writer.rs | 3 +- src/aztec/decoder.rs | 3 +- src/aztec/encoder/aztec_encoder.rs | 14 ++--- src/aztec/encoder/state.rs | 2 +- .../result/AddressBookAUResultParser.rs | 2 +- src/client/result/BizcardResultParser.rs | 2 +- src/client/result/CalendarParsedResult.rs | 15 ++---- .../ExpandedProductParsedResultTestCase.rs | 2 +- src/client/result/TelParsedResultTestCase.rs | 2 +- src/client/result/TelResultParser.rs | 2 +- src/client/result/VCardResultParser.rs | 2 +- src/client/result/VEventResultParser.rs | 2 +- src/common/BitArrayTestCase.rs | 12 ++--- src/common/bit_array.rs | 2 +- src/common/bit_matrix_test_case.rs | 2 +- src/common/eci_string_builder.rs | 2 +- src/common/minimal_eci_input.rs | 13 ++--- src/common/reedsolomon/ReedSolomonTestCase.rs | 8 ++- src/common/reedsolomon/generic_gf_poly.rs | 6 +-- src/common/reedsolomon/reedsolomon_decoder.rs | 3 +- src/datamatrix/data_matrix_writer.rs | 6 +-- .../decoder/decoded_bit_stream_parser.rs | 2 +- src/datamatrix/encoder/ascii_encoder.rs | 6 +-- src/datamatrix/encoder/base256_encoder.rs | 3 +- src/datamatrix/encoder/default_placement.rs | 2 +- src/datamatrix/encoder/error_correction.rs | 3 +- src/datamatrix/encoder/high_level_encoder.rs | 3 +- src/datamatrix/encoder/minimal_encoder.rs | 3 +- src/datamatrix/encoder/symbol_info.rs | 3 +- src/exceptions.rs | 26 ++++----- src/helpers.rs | 8 ++- .../decoder/decoded_bit_stream_parser.rs | 15 +++--- src/maxicode/detector.rs | 13 ++--- src/multi_format_writer.rs | 3 +- src/oned/coda_bar_writer.rs | 16 +++--- src/oned/code_128_reader.rs | 2 +- src/oned/code_128_writer.rs | 18 +++---- src/oned/code_128_writer_test_tase.rs | 2 +- src/oned/code_39_writer.rs | 11 ++-- src/oned/code_93_writer.rs | 5 +- src/oned/ean_13_writer.rs | 3 +- src/oned/ean_8_writer.rs | 3 +- src/oned/itf_writer.rs | 3 +- src/oned/one_d_code_writer.rs | 6 +-- .../decoders/abstract_expanded_decoder.rs | 3 +- .../expanded/decoders/ai_013103_decoder.rs | 9 ++-- .../decoders/ai_0132023203_decoder_test.rs | 6 +-- .../expanded/decoders/ai_013x0x1x_decoder.rs | 54 ++++--------------- .../rss/expanded/decoders/any_ai_decoder.rs | 26 +++------ .../rss/expanded/decoders/field_parser.rs | 8 +-- .../decoders/general_app_id_decoder.rs | 3 +- src/oned/rss/expanded/expanded_row.rs | 2 +- .../rss_expanded_image_2_binary_test_tase.rs | 2 +- .../rss_expanded_image_2_result_test_case.rs | 2 +- .../rss_expanded_image_2_string_test_case.rs | 2 +- .../rss_expanded_internal_test_case.rs | 3 +- src/oned/rss/expanded/test_case_util.rs | 2 +- src/oned/upc_a_writer.rs | 5 +- src/oned/upc_e_writer.rs | 3 +- src/oned/upc_ean_extension_5_support.rs | 4 +- src/oned/upc_ean_reader.rs | 2 +- src/pdf417/decoder/detection_result.rs | 2 +- src/pdf417/decoder/detection_result_column.rs | 2 +- src/pdf417/encoder/compaction.rs | 3 +- src/pdf417/encoder/pdf_417.rs | 2 +- .../encoder/pdf_417_high_level_encoder.rs | 3 +- src/pdf417/pdf_417_writer.rs | 3 +- src/planar_yuv_luminance_source.rs | 2 +- src/qrcode/decoder/bit_matrix_parser.rs | 3 +- src/qrcode/decoder/data_mask.rs | 3 +- src/qrcode/decoder/data_mask_testcase.rs | 2 +- .../decoder/decoded_bit_stream_parser.rs | 3 +- src/qrcode/decoder/error_correction_level.rs | 6 +-- src/qrcode/decoder/mode.rs | 3 +- src/qrcode/encoder/byte_matrix.rs | 2 +- src/qrcode/encoder/mask_util.rs | 3 +- src/qrcode/encoder/minimal_encoder.rs | 10 ++-- src/qrcode/encoder/qr_code.rs | 2 +- src/qrcode/encoder/qrcode_encoder.rs | 6 +-- src/qrcode/qr_code_writer.rs | 6 +-- src/rgb_luminance_source.rs | 2 +- tests/common/abstract_black_box_test_case.rs | 18 +++---- tests/common/pdf_417_multiimage_span.rs | 20 +++---- 86 files changed, 196 insertions(+), 335 deletions(-) diff --git a/src/aztec/DecoderTest.rs b/src/aztec/DecoderTest.rs index e18c5dc..ee52b58 100644 --- a/src/aztec/DecoderTest.rs +++ b/src/aztec/DecoderTest.rs @@ -77,8 +77,7 @@ fn test_high_level_decode_string(expectedString: &str, b: &str) { assert_eq!( expectedString, decoder::highLevelDecode(&toBooleanArray(&bits)).expect("highLevelDecode Failed"), - "highLevelDecode() failed for input bits: {}", - b + "highLevelDecode() failed for input bits: {b}" ); } diff --git a/src/aztec/DetectorTest.rs b/src/aztec/DetectorTest.rs index ce9b889..3271a9a 100644 --- a/src/aztec/DetectorTest.rs +++ b/src/aztec/DetectorTest.rs @@ -64,7 +64,7 @@ fn test_error_in_parameter_locator_compact() { #[test] fn test_error_in_parameter_locator_not_compact() { let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxyz"; - test_error_in_parameter_locator(&format!("{}{}{}", alphabet, alphabet, alphabet)); + test_error_in_parameter_locator(&format!("{alphabet}{alphabet}{alphabet}")); } #[test] @@ -165,7 +165,7 @@ fn test_error_in_parameter_locator(data: &str) { if let Exceptions::NotFoundException(_msg) = res { // all ok } else { - panic!("Only Exceptions::NotFoundException allowed, got {}", res); + panic!("Only Exceptions::NotFoundException allowed, got {res}"); } } else { let r = Detector::new(&make_larger(©, 3)).detect(false); diff --git a/src/aztec/EncoderTest.rs b/src/aztec/EncoderTest.rs index ccb03a6..c5891b2 100644 --- a/src/aztec/EncoderTest.rs +++ b/src/aztec/EncoderTest.rs @@ -617,7 +617,7 @@ fn testBorderCompact4CaseFailed() { // be error correction let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // encodes as 26 * 5 * 4 = 520 bits of data - let alphabet4 = format!("{}{}{}{}", alphabet, alphabet, alphabet, alphabet); + let alphabet4 = format!("{alphabet}{alphabet}{alphabet}{alphabet}"); aztec_encoder::encode(&alphabet4, 0, -4).expect("encode"); } @@ -627,7 +627,7 @@ fn testBorderCompact4Case() { // be error correction let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // encodes as 26 * 5 * 4 = 520 bits of data - let alphabet4 = format!("{}{}{}{}", alphabet, alphabet, alphabet, alphabet); + let alphabet4 = format!("{alphabet}{alphabet}{alphabet}{alphabet}"); // If we just try to encode it normally, it will go to a non-compact 4 layer let mut aztecCode = aztec_encoder::encode(&alphabet4, 0, aztec_encoder::DEFAULT_AZTEC_LAYERS) @@ -658,7 +658,7 @@ fn testEncode(data: &str, compact: bool, layers: u32, expected: &str) { // let mut xored = BitMatrix::parse_strings(&stripSpace(expected), "X ", " ").expect("should parse"); // xored.xor(matrix).expect("should xor"); - assert_eq!(expected, matrix.to_string(), "encode({}) failed", data); + assert_eq!(expected, matrix.to_string(), "encode({data}) failed"); } fn testEncodeDecode(data: &str, compact: bool, layers: u32) { @@ -814,8 +814,7 @@ fn testStuffBits(wordSize: usize, bits: &str, expected: &str) { assert_eq!( stripSpace(expected), stripSpace(&stuffed.to_string()), - "stuffBits() failed for input string: {}", - bits + "stuffBits() failed for input string: {bits}" ); } @@ -838,8 +837,7 @@ fn testHighLevelEncodeStringUtf8(s: &str, expectedBits: &str) { assert_eq!( stripSpace(expectedBits), receivedBits, - "highLevelEncode() failed for input string: {}", - s + "highLevelEncode() failed for input string: {s}" ); } @@ -856,8 +854,7 @@ fn testHighLevelEncodeString(s: &str, expectedBits: &str) { assert_eq!( stripSpace(expectedBits), receivedBits, - "highLevelEncode() failed for input string: {}", - s + "highLevelEncode() failed for input string: {s}" ); assert_eq!( s, @@ -888,7 +885,6 @@ fn testHighLevelEncodeStringCount(s: &str, expectedReceivedBits: u32) { // ); assert_eq!( expectedReceivedBits as usize, receivedBitCount, - "highLevelEncode() failed for input string: {} with byte count ({}!={})", - s, expectedReceivedBits, receivedBitCount + "highLevelEncode() failed for input string: {s} with byte count ({expectedReceivedBits}!={receivedBitCount})" ); } diff --git a/src/aztec/aztec_writer.rs b/src/aztec/aztec_writer.rs index c8b50a4..7b3e9a0 100644 --- a/src/aztec/aztec_writer.rs +++ b/src/aztec/aztec_writer.rs @@ -107,8 +107,7 @@ fn encode( ) -> Result { if format != BarcodeFormat::AZTEC { return Err(Exceptions::IllegalArgumentException(Some(format!( - "can only encode AZTEC, but got {:?}", - format + "can only encode AZTEC, but got {format:?}" )))); } let aztec = if let Some(cset) = charset { diff --git a/src/aztec/decoder.rs b/src/aztec/decoder.rs index 3c7282c..0e62c12 100644 --- a/src/aztec/decoder.rs +++ b/src/aztec/decoder.rs @@ -350,8 +350,7 @@ fn correct_bits( let num_codewords = rawbits.len() / codeword_size; if num_codewords < num_data_codewords as usize { return Err(Exceptions::FormatException(Some(format!( - "numCodewords {}< numDataCodewords{}", - num_codewords, num_data_codewords + "numCodewords {num_codewords}< numDataCodewords{num_data_codewords}" )))); } let mut offset = rawbits.len() % codeword_size; diff --git a/src/aztec/encoder/aztec_encoder.rs b/src/aztec/encoder/aztec_encoder.rs index 693a645..e5d7fe6 100644 --- a/src/aztec/encoder/aztec_encoder.rs +++ b/src/aztec/encoder/aztec_encoder.rs @@ -53,7 +53,7 @@ pub const WORD_SIZE: [u32; 33] = [ pub fn encode_simple(data: &str) -> Result { let Ok(bytes) = encoding::all::ISO_8859_1 .encode(data, encoding::EncoderTrap::Replace) else { - return Err(Exceptions::IllegalArgumentException(Some(format!("'{}' cannot be encoded as ISO_8859_1", data)))); + return Err(Exceptions::IllegalArgumentException(Some(format!("'{data}' cannot be encoded as ISO_8859_1")))); }; encode_bytes_simple(&bytes) } @@ -76,8 +76,7 @@ pub fn encode( encode_bytes(&bytes, minECCPercent, userSpecifiedLayers) } else { Err(Exceptions::IllegalArgumentException(Some(format!( - "'{}' cannot be encoded as ISO_8859_1", - data + "'{data}' cannot be encoded as ISO_8859_1" )))) } } @@ -104,8 +103,7 @@ pub fn encode_with_charset( encode_bytes_with_charset(&bytes, minECCPercent, userSpecifiedLayers, charset) } else { Err(Exceptions::IllegalArgumentException(Some(format!( - "'{}' cannot be encoded as ISO_8859_1", - data + "'{data}' cannot be encoded as ISO_8859_1" )))) } } @@ -181,8 +179,7 @@ pub fn encode_bytes_with_charset( }) { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Illegal value {} for layers", - user_specified_layers + "Illegal value {user_specified_layers} for layers" )))); } total_bits_in_layer_var = total_bits_in_layer(layers, compact); @@ -498,8 +495,7 @@ fn getGF(wordSize: usize) -> Result { 10 => Ok(get_predefined_genericgf(PredefinedGenericGF::AztecData10)), 12 => Ok(get_predefined_genericgf(PredefinedGenericGF::AztecData12)), _ => Err(Exceptions::IllegalArgumentException(Some(format!( - "Unsupported word size {}", - wordSize + "Unsupported word size {wordSize}" )))), } // switch (wordSize) { diff --git a/src/aztec/encoder/state.rs b/src/aztec/encoder/state.rs index ec646b3..ecd3780 100644 --- a/src/aztec/encoder/state.rs +++ b/src/aztec/encoder/state.rs @@ -86,7 +86,7 @@ impl State { // throw new IllegalArgumentException("ECI code must be between 0 and 999999"); } else { let eci_digits = encoding::all::ISO_8859_1 - .encode(&format!("{}", eci), encoding::EncoderTrap::Strict) + .encode(&format!("{eci}"), encoding::EncoderTrap::Strict) .unwrap(); // let eciDigits = Integer.toString(eci).getBytes(StandardCharsets.ISO_8859_1); token.add(eci_digits.len() as i32, 3); // 1-6: number of ECI digits diff --git a/src/client/result/AddressBookAUResultParser.rs b/src/client/result/AddressBookAUResultParser.rs index 1f409b5..bb8dbf6 100644 --- a/src/client/result/AddressBookAUResultParser.rs +++ b/src/client/result/AddressBookAUResultParser.rs @@ -89,7 +89,7 @@ fn matchMultipleValuePrefix(prefix: &str, rawText: &str) -> Vec { for i in 1..=3 { // for (int i = 1; i <= 3; i++) { let value = ResultParser::matchSinglePrefixedField( - &format!("{}{}:", prefix, i), + &format!("{prefix}{i}:"), rawText, '\r', true, diff --git a/src/client/result/BizcardResultParser.rs b/src/client/result/BizcardResultParser.rs index bb95629..28e2d4d 100644 --- a/src/client/result/BizcardResultParser.rs +++ b/src/client/result/BizcardResultParser.rs @@ -123,6 +123,6 @@ fn buildName(firstName: &str, lastName: &str) -> String { } else if lastName.is_empty() { firstName.to_owned() } else { - format!("{} {}", firstName, lastName) + format!("{firstName} {lastName}") } } diff --git a/src/client/result/CalendarParsedResult.rs b/src/client/result/CalendarParsedResult.rs index ee82947..2447645 100644 --- a/src/client/result/CalendarParsedResult.rs +++ b/src/client/result/CalendarParsedResult.rs @@ -196,8 +196,7 @@ impl CalendarParsedRXingResult { return match Utc.datetime_from_str(&when, "%Y%m%dT%H%M%SZ") { Ok(dtm) => Ok(dtm.with_timezone(&Utc).timestamp()), Err(e) => Err(Exceptions::ParseException(Some(format!( - "couldn't parse string: {}", - e + "couldn't parse string: {e}" )))), }; // let dtm = DateTime::parse_from_str(&when, "%Y%m%dT%H%M%S").unwrap().with_timezone(&Utc); @@ -219,16 +218,14 @@ impl CalendarParsedRXingResult { Ok(time_zone) => time_zone, Err(e) => { return Err(Exceptions::ParseException(Some(format!( - "couldn't parse timezone '{}': {}", - tz_part, e + "couldn't parse timezone '{tz_part}': {e}" )))) } }; return match Utc.datetime_from_str(time_part, "%Y%m%dT%H%M%S") { Ok(dtm) => Ok(dtm.with_timezone(&tz_parsed).timestamp()), Err(e) => Err(Exceptions::ParseException(Some(format!( - "couldn't parse string: {}", - e + "couldn't parse string: {e}" )))), }; } @@ -238,8 +235,7 @@ impl CalendarParsedRXingResult { return match Utc.datetime_from_str(&when, "%Y%m%dT%H%M%S") { Ok(dtm) => Ok(dtm.timestamp()), Err(e) => Err(Exceptions::ParseException(Some(format!( - "couldn't parse local time: {}", - e + "couldn't parse local time: {e}" )))), }; } @@ -300,8 +296,7 @@ impl CalendarParsedRXingResult { Ok(dtm.timestamp()) } else { Err(Exceptions::ParseException(Some(format!( - "Couldn't parse {}", - dateTimeString + "Couldn't parse {dateTimeString}" )))) } // DateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.ENGLISH); diff --git a/src/client/result/ExpandedProductParsedResultTestCase.rs b/src/client/result/ExpandedProductParsedResultTestCase.rs index e751483..9f34096 100644 --- a/src/client/result/ExpandedProductParsedResultTestCase.rs +++ b/src/client/result/ExpandedProductParsedResultTestCase.rs @@ -78,7 +78,7 @@ fn testRSSExpanded() { let ev = epr_res.getUncommonAIs().get(k).unwrap(); assert_eq!(v, ev); } else { - panic!("key not found {}", k) + panic!("key not found {k}") } } // assert_eq!(&uncommonAIs, epr_res.getUncommonAIs()); diff --git a/src/client/result/TelParsedResultTestCase.rs b/src/client/result/TelParsedResultTestCase.rs index 6bfd407..ccc6985 100644 --- a/src/client/result/TelParsedResultTestCase.rs +++ b/src/client/result/TelParsedResultTestCase.rs @@ -49,7 +49,7 @@ fn doTest(contents: &str, number: &str, title: &str) { if let ParsedClientResult::TelResult(telRXingResult) = result { assert_eq!(number, telRXingResult.getNumber()); assert_eq!(title, telRXingResult.getTitle()); - assert_eq!(format!("tel:{}", number), telRXingResult.getTelURI()); + assert_eq!(format!("tel:{number}"), telRXingResult.getTelURI()); } else { panic!("wrong return type, expected TelResult"); } diff --git a/src/client/result/TelResultParser.rs b/src/client/result/TelResultParser.rs index 37370e9..1d83756 100644 --- a/src/client/result/TelResultParser.rs +++ b/src/client/result/TelResultParser.rs @@ -36,7 +36,7 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option } // Normalize "TEL:" to "tel:" let telURI = if let Some(stripped) = rawText.strip_prefix("TEL:") { - format!("tel:{}", stripped) + format!("tel:{stripped}") } else { rawText.clone() }; diff --git a/src/client/result/VCardResultParser.rs b/src/client/result/VCardResultParser.rs index 5c80555..3311c33 100644 --- a/src/client/result/VCardResultParser.rs +++ b/src/client/result/VCardResultParser.rs @@ -182,7 +182,7 @@ pub fn matchVCardPrefixedField( // At start or after newline, match prefix, followed by optional metadata // (led by ;) ultimately ending in colon - let matcher_primary = Regex::new(&format!("(?:^|\\n)(?i:{})(?:;([^:]*))?:", prefix)).unwrap(); + let matcher_primary = Regex::new(&format!("(?:^|\\n)(?i:{prefix})(?:;([^:]*))?:")).unwrap(); // let matcher_primary = Regex::new(&format!("(?:^|\n){}(.*)", prefix)).unwrap(); //let lower_case_raw_text = rawText.to_lowercase(); diff --git a/src/client/result/VEventResultParser.rs b/src/client/result/VEventResultParser.rs index 7bae8ca..31887a7 100644 --- a/src/client/result/VEventResultParser.rs +++ b/src/client/result/VEventResultParser.rs @@ -134,7 +134,7 @@ fn matchSingleVCardPrefixedField(prefix: &str, rawText: &str) -> String { "".to_owned() }; let root_time = values.last().unwrap().clone(); - format!("{}{}", root_time, tz_mod) + format!("{root_time}{tz_mod}") } } else { "".to_owned() diff --git a/src/common/BitArrayTestCase.rs b/src/common/BitArrayTestCase.rs index 3309e6a..7225fd1 100644 --- a/src/common/BitArrayTestCase.rs +++ b/src/common/BitArrayTestCase.rs @@ -45,12 +45,12 @@ fn test_get_next_set1() { let array = BitArray::with_size(32); for i in 0..array.getSize() { // for (int i = 0; i < array.getSize(); i++) { - assert_eq!(32, array.getNextSet(i), "{}", i); + assert_eq!(32, array.getNextSet(i), "{i}"); } let array = BitArray::with_size(33); for i in 0..array.getSize() { // for (int i = 0; i < array.getSize(); i++) { - assert_eq!(33, array.getNextSet(i), "{}", i); + assert_eq!(33, array.getNextSet(i), "{i}"); } } @@ -60,13 +60,13 @@ fn test_get_next_set2() { array.set(31); for i in 0..array.getSize() { // for (int i = 0; i < array.getSize(); i++) { - assert_eq!(if i <= 31 { 31 } else { 33 }, array.getNextSet(i), "{}", i); + assert_eq!(if i <= 31 { 31 } else { 33 }, array.getNextSet(i), "{i}"); } array = BitArray::with_size(33); array.set(32); for i in 0..array.getSize() { // for (int i = 0; i < array.getSize(); i++) { - assert_eq!(32, array.getNextSet(i), "{}", i); + assert_eq!(32, array.getNextSet(i), "{i}"); } } @@ -85,7 +85,7 @@ fn test_get_next_set3() { } else { expected = 63; } - assert_eq!(expected, array.getNextSet(i), "{}", i); + assert_eq!(expected, array.getNextSet(i), "{i}"); } } @@ -104,7 +104,7 @@ fn test_get_next_set4() { } else { expected = 63; } - assert_eq!(expected, array.getNextSet(i), "{}", i); + assert_eq!(expected, array.getNextSet(i), "{i}"); } } diff --git a/src/common/bit_array.rs b/src/common/bit_array.rs index 676e80f..9482afd 100644 --- a/src/common/bit_array.rs +++ b/src/common/bit_array.rs @@ -393,7 +393,7 @@ impl fmt::Display for BitArray { } _str.push_str(if self.get(i) { "X" } else { "." }); } - write!(f, "{}", _str) + write!(f, "{_str}") } } diff --git a/src/common/bit_matrix_test_case.rs b/src/common/bit_matrix_test_case.rs index fa15672..7342afb 100644 --- a/src/common/bit_matrix_test_case.rs +++ b/src/common/bit_matrix_test_case.rs @@ -367,7 +367,7 @@ fn test_rotate_180(width: u32, height: u32) { // for (int y = 0; y < height; y++) { for x in 0..width { // for (int x = 0; x < width; x++) { - assert_eq!(expected.get(x, y), input.get(x, y), "({},{})", x, y); + assert_eq!(expected.get(x, y), input.get(x, y), "({x},{y})"); } } } diff --git a/src/common/eci_string_builder.rs b/src/common/eci_string_builder.rs index 57e435b..b826b6a 100644 --- a/src/common/eci_string_builder.rs +++ b/src/common/eci_string_builder.rs @@ -94,7 +94,7 @@ impl ECIStringBuilder { * @param value int to append as a string */ pub fn append(&mut self, value: i32) { - self.append_string(&format!("{}", value)); + self.append_string(&format!("{value}")); } /** diff --git a/src/common/minimal_eci_input.rs b/src/common/minimal_eci_input.rs index e5581d5..ce41751 100644 --- a/src/common/minimal_eci_input.rs +++ b/src/common/minimal_eci_input.rs @@ -79,8 +79,7 @@ impl ECIInput for MinimalECIInput { } if self.isECI(index as u32)? { return Err(Exceptions::IllegalArgumentException(Some(format!( - "value at {} is not a character but an ECI", - index + "value at {index} is not a character but an ECI" )))); } if self.isFNC1(index)? { @@ -119,8 +118,7 @@ impl ECIInput for MinimalECIInput { // for (int i = start; i < end; i++) { if self.isECI(i as u32)? { return Err(Exceptions::IllegalArgumentException(Some(format!( - "value at {} is not a character but an ECI", - i + "value at {i} is not a character but an ECI" )))); } result.push_str(&self.charAt(i)?.to_string()); @@ -170,8 +168,7 @@ impl ECIInput for MinimalECIInput { } if !self.isECI(index as u32)? { return Err(Exceptions::IllegalArgumentException(Some(format!( - "value at {} is not an ECI but a character", - index + "value at {index} is not an ECI but a character" )))); } Ok((self.bytes[index] as u32 - 256) as i32) @@ -352,7 +349,7 @@ impl MinimalECIInput { } } if minimalJ < 0 { - panic!("internal error: failed to encode \"{}\"", stringToEncode); + panic!("internal error: failed to encode \"{stringToEncode}\""); } let mut intsAL: Vec = Vec::new(); let mut current = edges[inputLength][minimalJ as usize].clone(); @@ -508,6 +505,6 @@ impl fmt::Display for MinimalECIInput { result.push(self.charAt(i).unwrap()); } } - write!(f, "{}", result) + write!(f, "{result}") } } diff --git a/src/common/reedsolomon/ReedSolomonTestCase.rs b/src/common/reedsolomon/ReedSolomonTestCase.rs index 4de6b2d..4dc95f5 100644 --- a/src/common/reedsolomon/ReedSolomonTestCase.rs +++ b/src/common/reedsolomon/ReedSolomonTestCase.rs @@ -398,13 +398,11 @@ public static void corrupt(int[] received, int howMany, Random random, int max) fn test_encode_decode_random(field: GenericGFRef, dataSize: usize, ecSize: usize) { assert!( dataSize > 0 && dataSize <= field.getSize() - 3, - "Invalid data size for {}", - field + "Invalid data size for {field}" ); assert!( ecSize > 0 && ecSize + dataSize <= field.getSize(), - "Invalid ECC size for {}", - field + "Invalid ECC size for {field}" ); let mut encoder = ReedSolomonEncoder::new(field); let mut message = vec![0; dataSize + ecSize]; @@ -427,7 +425,7 @@ fn test_encode_decode_random(field: GenericGFRef, dataSize: usize, ecSize: usize message[0..dataWords.len()].clone_from_slice(&dataWords[..]); //System.arraycopy(dataWords, 0, message, 0, dataWords.len()); if let Err(err) = encoder.encode(&mut message, ecWords.len()) { - panic!("{:#?}", err); + panic!("{err:#?}"); } ecWords[0..ecSize].clone_from_slice(&message[dataSize..dataSize + ecSize]); //System.arraycopy(message, dataSize, ecWords, 0, ecSize); diff --git a/src/common/reedsolomon/generic_gf_poly.rs b/src/common/reedsolomon/generic_gf_poly.rs index 17e083c..05a5833 100644 --- a/src/common/reedsolomon/generic_gf_poly.rs +++ b/src/common/reedsolomon/generic_gf_poly.rs @@ -319,7 +319,7 @@ impl fmt::Display for GenericGFPoly { result.push('a'); } else { result.push_str("a^"); - result.push_str(&format!("{}", alpha_power)); + result.push_str(&format!("{alpha_power}")); } } } @@ -328,11 +328,11 @@ impl fmt::Display for GenericGFPoly { result.push('x'); } else { result.push_str("x^"); - result.push_str(&format!("{}", degree)); + result.push_str(&format!("{degree}")); } } } } - write!(f, "{}", result) + write!(f, "{result}") } } diff --git a/src/common/reedsolomon/reedsolomon_decoder.rs b/src/common/reedsolomon/reedsolomon_decoder.rs index c43655b..a83d437 100644 --- a/src/common/reedsolomon/reedsolomon_decoder.rs +++ b/src/common/reedsolomon/reedsolomon_decoder.rs @@ -204,8 +204,7 @@ impl ReedSolomonDecoder { if r.getDegree() >= rLast.getDegree() { return Err(Exceptions::ReedSolomonException(Some(format!( - "Division algorithm failed to reduce polynomial? r: {}, rLast: {}", - r, rLast + "Division algorithm failed to reduce polynomial? r: {r}, rLast: {rLast}" )))); } } diff --git a/src/datamatrix/data_matrix_writer.rs b/src/datamatrix/data_matrix_writer.rs index e0b3152..ed0a5dc 100644 --- a/src/datamatrix/data_matrix_writer.rs +++ b/src/datamatrix/data_matrix_writer.rs @@ -67,15 +67,13 @@ impl Writer for DataMatrixWriter { if format != &BarcodeFormat::DATA_MATRIX { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Can only encode DATA_MATRIX, but got {:?}", - format + "Can only encode DATA_MATRIX, but got {format:?}" )))); } if width < 0 || height < 0 { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Requested dimensions can't be negative: {}x{}", - width, height + "Requested dimensions can't be negative: {width}x{height}" )))); } diff --git a/src/datamatrix/decoder/decoded_bit_stream_parser.rs b/src/datamatrix/decoder/decoded_bit_stream_parser.rs index 32a6b75..7a0135d 100644 --- a/src/datamatrix/decoder/decoded_bit_stream_parser.rs +++ b/src/datamatrix/decoder/decoded_bit_stream_parser.rs @@ -218,7 +218,7 @@ fn decodeAsciiSegment( result.append_char('0'); } //result.append_char(char::from_u32(value).unwrap()); - result.append_string(&format!("{}", value)); + result.append_string(&format!("{value}")); } else { match oneByte { 230=> // Latch to C40 encodation diff --git a/src/datamatrix/encoder/ascii_encoder.rs b/src/datamatrix/encoder/ascii_encoder.rs index ea9a87b..ca89461 100644 --- a/src/datamatrix/encoder/ascii_encoder.rs +++ b/src/datamatrix/encoder/ascii_encoder.rs @@ -74,8 +74,7 @@ impl Encoder for ASCIIEncoder { _ => { return Err(Exceptions::IllegalStateException(Some(format!( - "Illegal mode: {}", - newMode + "Illegal mode: {newMode}" )))); } } @@ -106,8 +105,7 @@ impl ASCIIEncoder { Ok((num + 130) as char) } else { Err(Exceptions::IllegalArgumentException(Some(format!( - "not digits: {}{}", - digit1, digit2 + "not digits: {digit1}{digit2}" )))) } } diff --git a/src/datamatrix/encoder/base256_encoder.rs b/src/datamatrix/encoder/base256_encoder.rs index b266efc..1143428 100644 --- a/src/datamatrix/encoder/base256_encoder.rs +++ b/src/datamatrix/encoder/base256_encoder.rs @@ -66,8 +66,7 @@ impl Encoder for Base256Encoder { buffer.insert(ci_pos, char::from_u32(dataCount as u32 % 250).unwrap()); } else { return Err(Exceptions::IllegalStateException(Some(format!( - "Message length not in valid ranges: {}", - dataCount + "Message length not in valid ranges: {dataCount}" )))); } } diff --git a/src/datamatrix/encoder/default_placement.rs b/src/datamatrix/encoder/default_placement.rs index b4b6a2c..6bf4628 100644 --- a/src/datamatrix/encoder/default_placement.rs +++ b/src/datamatrix/encoder/default_placement.rs @@ -275,7 +275,7 @@ mod test_placement { let actual = placement.toBitFieldStringArray(); for i in 0..actual.len() { // for (int i = 0; i < actual.length; i++) { - assert_eq!(expected[i], actual[i], "Row {}", i); + assert_eq!(expected[i], actual[i], "Row {i}"); } } diff --git a/src/datamatrix/encoder/error_correction.rs b/src/datamatrix/encoder/error_correction.rs index 79edb90..55a3f1d 100644 --- a/src/datamatrix/encoder/error_correction.rs +++ b/src/datamatrix/encoder/error_correction.rs @@ -221,8 +221,7 @@ fn createECCBlock(codewords: &str, numECWords: usize) -> Result Result<(), Exceptions> { // let hex = Integer.toHexString(c); // hex = "0000".substring(0, 4 - hex.length()) + hex; Err(Exceptions::IllegalArgumentException(Some(format!( - "Illegal character: {} (0x{})", - c, c + "Illegal character: {c} (0x{c})" )))) } diff --git a/src/datamatrix/encoder/minimal_encoder.rs b/src/datamatrix/encoder/minimal_encoder.rs index 6947693..1ca48c5 100755 --- a/src/datamatrix/encoder/minimal_encoder.rs +++ b/src/datamatrix/encoder/minimal_encoder.rs @@ -640,8 +640,7 @@ fn encodeMinimally(input: Rc) -> Result { if minimalJ < 0 { return Err(Exceptions::IllegalStateException(Some(format!( - "Internal error: failed to encode \"{}\"", - input + "Internal error: failed to encode \"{input}\"" )))); } RXingResult::new(edges[inputLength][minimalJ as usize].clone()) diff --git a/src/datamatrix/encoder/symbol_info.rs b/src/datamatrix/encoder/symbol_info.rs index 8f66e05..9b548c2 100644 --- a/src/datamatrix/encoder/symbol_info.rs +++ b/src/datamatrix/encoder/symbol_info.rs @@ -346,8 +346,7 @@ impl<'a> SymbolInfoLookup<'a> { } if fail { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Can't find a symbol arrangement that matches the message. Data codewords: {}", - dataCodewords + "Can't find a symbol arrangement that matches the message. Data codewords: {dataCodewords}" )))); } Ok(None) diff --git a/src/exceptions.rs b/src/exceptions.rs index 7f9a45e..fce786b 100644 --- a/src/exceptions.rs +++ b/src/exceptions.rs @@ -22,29 +22,29 @@ impl fmt::Display for Exceptions { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Exceptions::IllegalArgumentException(Some(a)) => { - write!(f, "IllegalArgumentException - {}", a) + write!(f, "IllegalArgumentException - {a}") } Exceptions::UnsupportedOperationException(Some(a)) => { - write!(f, "UnsupportedOperationException - {}", a) + write!(f, "UnsupportedOperationException - {a}") } Exceptions::IllegalStateException(Some(a)) => { - write!(f, "IllegalStateException - {}", a) + write!(f, "IllegalStateException - {a}") } - Exceptions::ArithmeticException(Some(a)) => write!(f, "ArithmeticException - {}", a), - Exceptions::NotFoundException(Some(a)) => write!(f, "NotFoundException - {}", a), - Exceptions::FormatException(Some(a)) => write!(f, "FormatException - {}", a), - Exceptions::ChecksumException(Some(a)) => write!(f, "ChecksumException - {}", a), - Exceptions::ReaderException(Some(a)) => write!(f, "ReaderException - {}", a), - Exceptions::WriterException(Some(a)) => write!(f, "WriterException - {}", a), - Exceptions::ReedSolomonException(Some(a)) => write!(f, "ReedSolomonException - {}", a), + Exceptions::ArithmeticException(Some(a)) => write!(f, "ArithmeticException - {a}"), + Exceptions::NotFoundException(Some(a)) => write!(f, "NotFoundException - {a}"), + Exceptions::FormatException(Some(a)) => write!(f, "FormatException - {a}"), + Exceptions::ChecksumException(Some(a)) => write!(f, "ChecksumException - {a}"), + Exceptions::ReaderException(Some(a)) => write!(f, "ReaderException - {a}"), + Exceptions::WriterException(Some(a)) => write!(f, "WriterException - {a}"), + Exceptions::ReedSolomonException(Some(a)) => write!(f, "ReedSolomonException - {a}"), Exceptions::IndexOutOfBoundsException(Some(a)) => { - write!(f, "IndexOutOfBoundsException - {}", a) + write!(f, "IndexOutOfBoundsException - {a}") } - Exceptions::RuntimeException(Some(a)) => write!(f, "RuntimeException - {}", a), - Exceptions::ParseException(Some(a)) => write!(f, "ParseException - {}", a), + Exceptions::RuntimeException(Some(a)) => write!(f, "RuntimeException - {a}"), + Exceptions::ParseException(Some(a)) => write!(f, "ParseException - {a}"), Exceptions::IllegalArgumentException(None) => write!(f, "IllegalArgumentException"), diff --git a/src/helpers.rs b/src/helpers.rs index 2d624f6..b474df4 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -134,7 +134,7 @@ pub fn detect_in_file_with_hints( hints: &mut DecodingHintDictionary, ) -> Result { let Ok(img) = image::open(file_name) else { - return Err(Exceptions::IllegalArgumentException(Some(format!("file '{}' not found or cannot be opened", file_name)))); + return Err(Exceptions::IllegalArgumentException(Some(format!("file '{file_name}' not found or cannot be opened")))); }; let mut multi_format_reader = MultiFormatReader::default(); @@ -255,8 +255,7 @@ pub fn save_image(file_name: &str, bit_matrix: &BitMatrix) -> Result<(), Excepti match image.save(file_name) { Ok(_) => Ok(()), Err(err) => Err(Exceptions::IllegalArgumentException(Some(format!( - "could not save file '{}': {}", - file_name, err + "could not save file '{file_name}': {err}" )))), } } @@ -303,8 +302,7 @@ pub fn save_file(file_name: &str, bit_matrix: &BitMatrix) -> Result<(), Exceptio }() { Ok(_) => Ok(()), Err(_) => Err(Exceptions::IllegalArgumentException(Some(format!( - "could not write to '{}'", - file_name + "could not write to '{file_name}'" )))), } } diff --git a/src/maxicode/decoder/decoded_bit_stream_parser.rs b/src/maxicode/decoder/decoded_bit_stream_parser.rs index 429d799..6d4e318 100644 --- a/src/maxicode/decoder/decoded_bit_stream_parser.rs +++ b/src/maxicode/decoder/decoded_bit_stream_parser.rs @@ -61,11 +61,8 @@ const POSTCODE_3_BYTES: [[u8; 6]; 6] = [ static SETS: Lazy<[String; 5]> = Lazy::new(|| { [ - format!("\rABCDEFGHIJKLMNOPQRSTUVWXYZ{}{}{}{}{} {}\"#$%&'()*+,-./0123456789:{}{}{}{}{}" , ECI , FS , GS , RS , NS , PAD , - SHIFTB , SHIFTC , SHIFTD , SHIFTE , LATCHB), - format!("`abcdefghijklmnopqrstuvwxyz{}{}{}{}{}{{{}}}~\u{007F};<=>?[\\]^_ ,./:@!|{}{}{}{}{}{}{}{}{}" , ECI , FS , GS , RS , NS ,PAD , - PAD , TWOSHIFTA , THREESHIFTA , PAD , - SHIFTA , SHIFTC , SHIFTD , SHIFTE , LATCHA), + format!("\rABCDEFGHIJKLMNOPQRSTUVWXYZ{ECI}{FS}{GS}{RS}{NS} {PAD}\"#$%&'()*+,-./0123456789:{SHIFTB}{SHIFTC}{SHIFTD}{SHIFTE}{LATCHB}" ), + format!("`abcdefghijklmnopqrstuvwxyz{ECI}{FS}{GS}{RS}{NS}{{{PAD}}}~\u{007F};<=>?[\\]^_ ,./:@!|{PAD}{TWOSHIFTA}{THREESHIFTA}{PAD}{SHIFTA}{SHIFTC}{SHIFTD}{SHIFTE}{LATCHA}" ), format!("\u{00C0}\u{00C1}\u{00C2}\u{00C3}\u{00C4}\u{00C5}\u{00C6}\u{00C7}\u{00C8}\u{00C9}\u{00CA}\u{00CB}\u{00CC}\u{00CD}\u{00CE}\u{00CF}\u{00D0}\u{00D1}\u{00D2}\u{00D3}\u{00D4}\u{00D5}\u{00D6}\u{00D7}\u{00D8}\u{00D9}\u{00DA}{}{}{}{}{}{}{}{}{}{}{}{}" , ECI , FS , GS , RS , NS , "\u{00DB}\u{00DC}\u{00DD}\u{00DE}\u{00DF}\u{00AA}\u{00AC}\u{00B1}\u{00B2}\u{00B3}\u{00B5}\u{00B9}\u{00BA}\u{00BC}\u{00BD}\u{00BE}\u{0080}\u{0081}\u{0082}\u{0083}\u{0084}\u{0085}\u{0086}\u{0087}\u{0088}\u{0089}" , @@ -93,7 +90,7 @@ pub fn decode(bytes: &[u8], mode: u8) -> Result } // NumberFormat df = new DecimalFormat("0000000000".substring(0, ps2Length)); // postcode = df.format(pc); - format!("{:0>ps2Length$}", pc) + format!("{pc:0>ps2Length$}") } else { getPostCode3(bytes) }; @@ -106,12 +103,12 @@ pub fn decode(bytes: &[u8], mode: u8) -> Result if result.starts_with(&format!("[)>{}{}{}", RS, "01", GS)) { result.insert_str( 9, - &format!("{}{}{}{}{}{}", postcode, GS, country, GS, service, GS), + &format!("{postcode}{GS}{country}{GS}{service}{GS}"), ); } else { result.insert_str( 0, - &format!("{}{}{}{}{}{}", postcode, GS, country, GS, service, GS), + &format!("{postcode}{GS}{country}{GS}{service}{GS}"), ); } } @@ -226,7 +223,7 @@ fn getMessage(bytes: &[u8], start: u32, len: u32) -> String { i += 1; nsval += bytes[i as usize] as u32; // sb.append(new DecimalFormat("000000000").format(nsval));}, - sb.push_str(&format!("{:0>9}", nsval)); + sb.push_str(&format!("{nsval:0>9}")); } LOCK => { shift = -1; diff --git a/src/maxicode/detector.rs b/src/maxicode/detector.rs index 007de57..42eb930 100644 --- a/src/maxicode/detector.rs +++ b/src/maxicode/detector.rs @@ -140,11 +140,12 @@ impl<'a> Circle<'_> { // find semi-major and semi-minor axi let mut lengths = [(0, 0.0, [(0.0_f32, 0.0); 2]); 72]; let mut circle_points = Vec::new(); - for i_rotation in 0..72 { + // for i_rotation in 0..72 { + for (i_rotation, length_set) in lengths.iter_mut().enumerate(){ let rotation = i_rotation as f32 * 5.0; let (length, points) = self.find_width_at_degree(rotation); circle_points.extend_from_slice(&points); - lengths[i_rotation] = (length, rotation, points); + *length_set = (length, rotation, points); } lengths.sort_by_key(|e| e.0); let major_axis = lengths.last().unwrap(); @@ -352,12 +353,12 @@ pub fn detect(image: &BitMatrix, try_harder: bool) -> Result Box::::default(), _ => { return Err(Exceptions::IllegalArgumentException(Some(format!( - "No encoder available for format {:?}", - format + "No encoder available for format {format:?}" )))) } }; diff --git a/src/oned/coda_bar_writer.rs b/src/oned/coda_bar_writer.rs index 1c08cf7..fd4a4cb 100644 --- a/src/oned/coda_bar_writer.rs +++ b/src/oned/coda_bar_writer.rs @@ -37,7 +37,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter { fn encode_oned(&self, contents: &str) -> Result, crate::Exceptions> { let contents = if contents.chars().count() < 2 { // Can't have a start/end guard, so tentatively add default guards - format!("{}{}{}", DEFAULT_GUARD, contents, DEFAULT_GUARD) + format!("{DEFAULT_GUARD}{contents}{DEFAULT_GUARD}") } else { // Verify input and calculate decoded length. let firstChar = contents.chars().next().unwrap().to_ascii_uppercase(); @@ -53,8 +53,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter { if startsNormal { if !endsNormal { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Invalid start/end guards: {}", - contents + "Invalid start/end guards: {contents}" )))); } // else already has valid start/end @@ -62,8 +61,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter { } else if startsAlt { if !endsAlt { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Invalid start/end guards: {}", - contents + "Invalid start/end guards: {contents}" )))); } // else already has valid start/end @@ -72,12 +70,11 @@ impl OneDimensionalCodeWriter for CodaBarWriter { // Doesn't start with a guard if endsNormal || endsAlt { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Invalid start/end guards: {}", - contents + "Invalid start/end guards: {contents}" )))); } // else doesn't end with guard either, so add a default - format!("{}{}{}", DEFAULT_GUARD, contents, DEFAULT_GUARD) + format!("{DEFAULT_GUARD}{contents}{DEFAULT_GUARD}") } }; @@ -95,8 +92,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter { resultLength += 10; } else { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Cannot encode : '{}'", - ch + "Cannot encode : '{ch}'" )))); } } diff --git a/src/oned/code_128_reader.rs b/src/oned/code_128_reader.rs index 6355e64..9628142 100644 --- a/src/oned/code_128_reader.rs +++ b/src/oned/code_128_reader.rs @@ -356,7 +356,7 @@ impl OneDReader for Code128Reader { resultObject.putMetadata( RXingResultMetadataType::SYMBOLOGY_IDENTIFIER, - RXingResultMetadataValue::SymbologyIdentifier(format!("]C{}", symbologyModifier)), + RXingResultMetadataValue::SymbologyIdentifier(format!("]C{symbologyModifier}")), ); Ok(resultObject) diff --git a/src/oned/code_128_writer.rs b/src/oned/code_128_writer.rs index aa5f314..a795968 100644 --- a/src/oned/code_128_writer.rs +++ b/src/oned/code_128_writer.rs @@ -96,8 +96,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result Result forcedCodeSet = CODE_CODE_C as i32, _ => { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Unsupported code set hint: {}", - codeSetHint + "Unsupported code set hint: {codeSetHint}" )))) } } @@ -133,8 +131,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result Result 95 && c <= 127 { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Bad character in input for forced code set A: ASCII value={}", - c + "Bad character in input for forced code set A: ASCII value={c}" )))); } } @@ -159,8 +155,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result Result 80 { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Requested contents should be less than 80 digits long, but got {}", - length + "Requested contents should be less than 80 digits long, but got {length}" )))); } @@ -50,7 +49,7 @@ impl OneDimensionalCodeWriter for Code39Writer { contents = Self::tryToConvertToExtendedMode(&contents)?; length = contents.chars().count(); if length > 80 { - return Err(Exceptions::IllegalArgumentException(Some(format!("Requested contents should be less than 80 digits long, but got {} (extended full ASCII mode)",length)))); + return Err(Exceptions::IllegalArgumentException(Some(format!("Requested contents should be less than 80 digits long, but got {length} (extended full ASCII mode)")))); } break; } @@ -156,8 +155,7 @@ impl Code39Writer { .push(char::from_u32('P' as u32 + (character as u32 - 123)).unwrap()); } else { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Requested content contains a non-encodable character: '{}'", - character + "Requested content contains a non-encodable character: '{character}'" )))); } } @@ -249,8 +247,7 @@ mod Code39WriterTestCase { assert_eq!( expected, bit_matrix_test_case::matrix_to_string(&result), - "{}", - input + "{input}" ); } } diff --git a/src/oned/code_93_writer.rs b/src/oned/code_93_writer.rs index d99ca56..14c0ced 100644 --- a/src/oned/code_93_writer.rs +++ b/src/oned/code_93_writer.rs @@ -35,7 +35,7 @@ impl OneDimensionalCodeWriter for Code93Writer { let mut contents = Self::convertToExtended(contents)?; let length = contents.chars().count(); if length > 80 { - return Err(Exceptions::IllegalArgumentException(Some(format!("Requested contents should be less than 80 digits long after converting to extended encoding, but got {}" , length)))); + return Err(Exceptions::IllegalArgumentException(Some(format!("Requested contents should be less than 80 digits long after converting to extended encoding, but got {length}" )))); } //length of code + 2 start/stop characters + 2 checksums, each of 9 bits, plus a termination bar @@ -197,8 +197,7 @@ impl Code93Writer { .push(char::from_u32('P' as u32 + character as u32 - '{' as u32).unwrap()); } else { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Requested content contains a non-encodable character: '{}'", - character + "Requested content contains a non-encodable character: '{character}'" )))); } } diff --git a/src/oned/ean_13_writer.rs b/src/oned/ean_13_writer.rs index 01c8a49..189d2b5 100644 --- a/src/oned/ean_13_writer.rs +++ b/src/oned/ean_13_writer.rs @@ -61,8 +61,7 @@ impl OneDimensionalCodeWriter for EAN13Writer { } _ => { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Requested contents should be 12 or 13 digits long, but got {}", - length + "Requested contents should be 12 or 13 digits long, but got {length}" )))) } } diff --git a/src/oned/ean_8_writer.rs b/src/oned/ean_8_writer.rs index ff18a0a..721c7d0 100644 --- a/src/oned/ean_8_writer.rs +++ b/src/oned/ean_8_writer.rs @@ -71,8 +71,7 @@ impl OneDimensionalCodeWriter for EAN8Writer { // }}, _ => { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Requested contents should be 7 or 8 digits long, but got {}", - length + "Requested contents should be 7 or 8 digits long, but got {length}" )))) } } diff --git a/src/oned/itf_writer.rs b/src/oned/itf_writer.rs index bee2ec3..a926b7a 100644 --- a/src/oned/itf_writer.rs +++ b/src/oned/itf_writer.rs @@ -38,8 +38,7 @@ impl OneDimensionalCodeWriter for ITFWriter { } if length > 80 { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Requested contents should be less than 80 digits long, but got {}", - length + "Requested contents should be less than 80 digits long, but got {length}" )))); } diff --git a/src/oned/one_d_code_writer.rs b/src/oned/one_d_code_writer.rs index 48c7097..2fb2837 100644 --- a/src/oned/one_d_code_writer.rs +++ b/src/oned/one_d_code_writer.rs @@ -173,15 +173,13 @@ impl Writer for L { if width < 0 || height < 0 { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Negative size is not allowed. Input: {}x{}", - width, height + "Negative size is not allowed. Input: {width}x{height}" )))); } if let Some(supportedFormats) = self.getSupportedWriteFormats() { if !supportedFormats.contains(format) { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Can only encode {:?}, but got {:?}", - supportedFormats, format + "Can only encode {supportedFormats:?}, but got {format:?}" )))); } } diff --git a/src/oned/rss/expanded/decoders/abstract_expanded_decoder.rs b/src/oned/rss/expanded/decoders/abstract_expanded_decoder.rs index e7dbe58..62d15d3 100644 --- a/src/oned/rss/expanded/decoders/abstract_expanded_decoder.rs +++ b/src/oned/rss/expanded/decoders/abstract_expanded_decoder.rs @@ -150,7 +150,6 @@ pub fn createDecoder<'a>( } Err(Exceptions::IllegalStateException(Some(format!( - "unknown decoder: {}", - information + "unknown decoder: {information}" )))) } diff --git a/src/oned/rss/expanded/decoders/ai_013103_decoder.rs b/src/oned/rss/expanded/decoders/ai_013103_decoder.rs index dd34941..32b7b5a 100644 --- a/src/oned/rss/expanded/decoders/ai_013103_decoder.rs +++ b/src/oned/rss/expanded/decoders/ai_013103_decoder.rs @@ -83,8 +83,7 @@ mod AI013103DecoderTest { #[test] fn test0131031() { let data = format!( - "{}{}{}", - HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT1750 + "{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT1750}" ); let expected = "(01)90012345678908(3103)001750"; assertCorrectBinaryString(&data, expected); @@ -93,8 +92,7 @@ mod AI013103DecoderTest { #[test] fn test0131032() { let data = format!( - "{}{}{}", - HEADER, COMPRESSED_GTIN900000000000008, COMPRESSED15BIT_WEIGHT0 + "{HEADER}{COMPRESSED_GTIN900000000000008}{COMPRESSED15BIT_WEIGHT0}" ); let expected = "(01)90000000000003(3103)000000"; assertCorrectBinaryString(&data, expected); @@ -104,8 +102,7 @@ mod AI013103DecoderTest { #[should_panic] fn test013103invalid() { let data = format!( - "{}{}{}..", - HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT1750 + "{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT1750}.." ); assertCorrectBinaryString(&data, ""); } diff --git a/src/oned/rss/expanded/decoders/ai_0132023203_decoder_test.rs b/src/oned/rss/expanded/decoders/ai_0132023203_decoder_test.rs index 25733f7..b2055e9 100644 --- a/src/oned/rss/expanded/decoders/ai_0132023203_decoder_test.rs +++ b/src/oned/rss/expanded/decoders/ai_0132023203_decoder_test.rs @@ -35,8 +35,7 @@ const HEADER: &str = "..X.X"; #[test] fn test0132021() { let data = format!( - "{}{}{}", - HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT1750 + "{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT1750}" ); let expected = "(01)90012345678908(3202)001750"; @@ -46,8 +45,7 @@ fn test0132021() { #[test] fn test0132031() { let data = format!( - "{}{}{}", - HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT11750 + "{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT11750}" ); let expected = "(01)90012345678908(3203)001750"; diff --git a/src/oned/rss/expanded/decoders/ai_013x0x1x_decoder.rs b/src/oned/rss/expanded/decoders/ai_013x0x1x_decoder.rs index 6ee8153..ab25f1f 100644 --- a/src/oned/rss/expanded/decoders/ai_013x0x1x_decoder.rs +++ b/src/oned/rss/expanded/decoders/ai_013x0x1x_decoder.rs @@ -151,11 +151,7 @@ mod AI013X0X1XDecoderTest { #[test] fn test01310X1XendDate() { let data = format!( - "{}{}{}{}", - HEADER310X11, - COMPRESSED_GTIN900123456798908, - COMPRESSED20BIT_WEIGHT1750, - COMPRESSED_DATE_END + "{HEADER310X11}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_END}" ); let expected = "(01)90012345678908(3100)001750"; @@ -165,11 +161,7 @@ mod AI013X0X1XDecoderTest { #[test] fn test01310X111() { let data = format!( - "{}{}{}{}", - HEADER310X11, - COMPRESSED_GTIN900123456798908, - COMPRESSED20BIT_WEIGHT1750, - COMPRESSED_DATE_MARCH12TH2010 + "{HEADER310X11}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}" ); let expected = "(01)90012345678908(3100)001750(11)100312"; @@ -179,11 +171,7 @@ mod AI013X0X1XDecoderTest { #[test] fn test01320X111() { let data = format!( - "{}{}{}{}", - HEADER320X11, - COMPRESSED_GTIN900123456798908, - COMPRESSED20BIT_WEIGHT1750, - COMPRESSED_DATE_MARCH12TH2010 + "{HEADER320X11}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}" ); let expected = "(01)90012345678908(3200)001750(11)100312"; @@ -193,11 +181,7 @@ mod AI013X0X1XDecoderTest { #[test] fn test01310X131() { let data = format!( - "{}{}{}{}", - HEADER310X13, - COMPRESSED_GTIN900123456798908, - COMPRESSED20BIT_WEIGHT1750, - COMPRESSED_DATE_MARCH12TH2010 + "{HEADER310X13}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}" ); let expected = "(01)90012345678908(3100)001750(13)100312"; @@ -207,11 +191,7 @@ mod AI013X0X1XDecoderTest { #[test] fn test01320X131() { let data = format!( - "{}{}{}{}", - HEADER320X13, - COMPRESSED_GTIN900123456798908, - COMPRESSED20BIT_WEIGHT1750, - COMPRESSED_DATE_MARCH12TH2010 + "{HEADER320X13}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}" ); let expected = "(01)90012345678908(3200)001750(13)100312"; @@ -221,11 +201,7 @@ mod AI013X0X1XDecoderTest { #[test] fn test01310X151() { let data = format!( - "{}{}{}{}", - HEADER310X15, - COMPRESSED_GTIN900123456798908, - COMPRESSED20BIT_WEIGHT1750, - COMPRESSED_DATE_MARCH12TH2010 + "{HEADER310X15}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}" ); let expected = "(01)90012345678908(3100)001750(15)100312"; @@ -235,11 +211,7 @@ mod AI013X0X1XDecoderTest { #[test] fn test01320X151() { let data = format!( - "{}{}{}{}", - HEADER320X15, - COMPRESSED_GTIN900123456798908, - COMPRESSED20BIT_WEIGHT1750, - COMPRESSED_DATE_MARCH12TH2010 + "{HEADER320X15}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}" ); let expected = "(01)90012345678908(3200)001750(15)100312"; @@ -249,11 +221,7 @@ mod AI013X0X1XDecoderTest { #[test] fn test01310X171() { let data = format!( - "{}{}{}{}", - HEADER310X17, - COMPRESSED_GTIN900123456798908, - COMPRESSED20BIT_WEIGHT1750, - COMPRESSED_DATE_MARCH12TH2010 + "{HEADER310X17}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}" ); let expected = "(01)90012345678908(3100)001750(17)100312"; @@ -263,11 +231,7 @@ mod AI013X0X1XDecoderTest { #[test] fn test01320X171() { let data = format!( - "{}{}{}{}", - HEADER320X17, - COMPRESSED_GTIN900123456798908, - COMPRESSED20BIT_WEIGHT1750, - COMPRESSED_DATE_MARCH12TH2010 + "{HEADER320X17}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}" ); let expected = "(01)90012345678908(3200)001750(17)100312"; diff --git a/src/oned/rss/expanded/decoders/any_ai_decoder.rs b/src/oned/rss/expanded/decoders/any_ai_decoder.rs index 0df2a63..a551039 100644 --- a/src/oned/rss/expanded/decoders/any_ai_decoder.rs +++ b/src/oned/rss/expanded/decoders/any_ai_decoder.rs @@ -70,8 +70,7 @@ mod AnyAIDecoderTest { #[test] fn testAnyAIDecoder1() { let data = format!( - "{}{}{}{}{}{}{}", - HEADER, NUMERIC10, NUMERIC12, NUMERIC2ALPHA, ALPHA_A, ALPHA2NUMERIC, NUMERIC12 + "{HEADER}{NUMERIC10}{NUMERIC12}{NUMERIC2ALPHA}{ALPHA_A}{ALPHA2NUMERIC}{NUMERIC12}" ); let expected = "(10)12A12"; @@ -81,8 +80,7 @@ mod AnyAIDecoderTest { #[test] fn testAnyAIDecoder2() { let data = format!( - "{}{}{}{}{}{}{}", - HEADER, NUMERIC10, NUMERIC12, NUMERIC2ALPHA, ALPHA_A, ALPHA2ISOIEC646, I646_B + "{HEADER}{NUMERIC10}{NUMERIC12}{NUMERIC2ALPHA}{ALPHA_A}{ALPHA2ISOIEC646}{I646_B}" ); let expected = "(10)12AB"; @@ -92,17 +90,7 @@ mod AnyAIDecoderTest { #[test] fn testAnyAIDecoder3() { let data = format!( - "{}{}{}{}{}{}{}{}{}{}", - HEADER, - NUMERIC10, - NUMERIC2ALPHA, - ALPHA2ISOIEC646, - I646_B, - I646_C, - ISOIEC6462ALPHA, - ALPHA_A, - ALPHA2NUMERIC, - NUMERIC10 + "{HEADER}{NUMERIC10}{NUMERIC2ALPHA}{ALPHA2ISOIEC646}{I646_B}{I646_C}{ISOIEC6462ALPHA}{ALPHA_A}{ALPHA2NUMERIC}{NUMERIC10}" ); let expected = "(10)BCA10"; @@ -111,7 +99,7 @@ mod AnyAIDecoderTest { #[test] fn testAnyAIDecodernumericFNC1secondDigit() { - let data = format!("{}{}{}", HEADER, NUMERIC10, NUMERIC1_FNC1); + let data = format!("{HEADER}{NUMERIC10}{NUMERIC1_FNC1}"); let expected = "(10)1"; assertCorrectBinaryString(&data, expected); @@ -120,8 +108,7 @@ mod AnyAIDecoderTest { #[test] fn testAnyAIDecoderalphaFNC1() { let data = format!( - "{}{}{}{}{}", - HEADER, NUMERIC10, NUMERIC2ALPHA, ALPHA_A, ALPHA_FNC1 + "{HEADER}{NUMERIC10}{NUMERIC2ALPHA}{ALPHA_A}{ALPHA_FNC1}" ); let expected = "(10)A"; @@ -131,8 +118,7 @@ mod AnyAIDecoderTest { #[test] fn testAnyAIDecoder646FNC1() { let data = format!( - "{}{}{}{}{}{}{}", - HEADER, NUMERIC10, NUMERIC2ALPHA, ALPHA_A, ISOIEC6462ALPHA, I646_B, I646_FNC1 + "{HEADER}{NUMERIC10}{NUMERIC2ALPHA}{ALPHA_A}{ISOIEC6462ALPHA}{I646_B}{I646_FNC1}" ); let expected = "(10)AB"; diff --git a/src/oned/rss/expanded/decoders/field_parser.rs b/src/oned/rss/expanded/decoders/field_parser.rs index 70c85a9..8f2bbda 100644 --- a/src/oned/rss/expanded/decoders/field_parser.rs +++ b/src/oned/rss/expanded/decoders/field_parser.rs @@ -215,13 +215,13 @@ fn processFixedAI( .take(fieldSize) .collect(); //rawInformation.substring(aiSize, aiSize + fieldSize); let remaining: String = rawInformation.chars().skip(aiSize + fieldSize).collect(); // rawInformation.substring(aiSize + fieldSize); - let result = format!("({}){}", ai, field); + let result = format!("({ai}){field}"); let parsedAI = parseFieldsInGeneralPurpose(&remaining)?; Ok(if parsedAI.is_empty() { result } else { - format!("{}{}", result, parsedAI) + format!("{result}{parsedAI}") }) } @@ -237,13 +237,13 @@ fn processVariableAI( .min(aiSize + variableFieldSize); let field: String = rawInformation.chars().skip(aiSize).take(maxSize).collect(); // (aiSize, maxSize); let remaining: String = rawInformation.chars().skip(maxSize).collect(); - let result = format!("({}){}", ai, field); //'(' + ai + ')' + field; + let result = format!("({ai}){field}"); //'(' + ai + ')' + field; let parsedAI = parseFieldsInGeneralPurpose(&remaining)?; Ok(if parsedAI.is_empty() { result } else { - format!("{}{}", result, parsedAI) + format!("{result}{parsedAI}") }) } diff --git a/src/oned/rss/expanded/decoders/general_app_id_decoder.rs b/src/oned/rss/expanded/decoders/general_app_id_decoder.rs index d491008..e03eb77 100644 --- a/src/oned/rss/expanded/decoders/general_app_id_decoder.rs +++ b/src/oned/rss/expanded/decoders/general_app_id_decoder.rs @@ -445,8 +445,7 @@ impl<'a> GeneralAppIdDecoder<'_> { 62 => '/', _ => { return Err(Exceptions::IllegalStateException(Some(format!( - "Decoding invalid alphanumeric value: {}", - sixBitValue + "Decoding invalid alphanumeric value: {sixBitValue}" )))) } }; diff --git a/src/oned/rss/expanded/expanded_row.rs b/src/oned/rss/expanded/expanded_row.rs index 6388418..e17f684 100644 --- a/src/oned/rss/expanded/expanded_row.rs +++ b/src/oned/rss/expanded/expanded_row.rs @@ -68,7 +68,7 @@ impl Display for ExpandedRow { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{{ ")?; for p in &self.pairs { - write!(f, "{}", p)?; + write!(f, "{p}")?; } write!(f, " }}") //{:?} }} " , self.pairs ) } diff --git a/src/oned/rss/expanded/rss_expanded_image_2_binary_test_tase.rs b/src/oned/rss/expanded/rss_expanded_image_2_binary_test_tase.rs index 3dc1c25..a576301 100644 --- a/src/oned/rss/expanded/rss_expanded_image_2_binary_test_tase.rs +++ b/src/oned/rss/expanded/rss_expanded_image_2_binary_test_tase.rs @@ -171,7 +171,7 @@ fn testDecodeRow2binary22() { } fn assertCorrectImage2binary(fileName: &str, expected: &str) { - let path = format!("test_resources/blackbox/rssexpanded-1/{}", fileName); + let path = format!("test_resources/blackbox/rssexpanded-1/{fileName}"); let image = image::open(path).expect("file exists"); let binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new( diff --git a/src/oned/rss/expanded/rss_expanded_image_2_result_test_case.rs b/src/oned/rss/expanded/rss_expanded_image_2_result_test_case.rs index 55cc341..21a096f 100644 --- a/src/oned/rss/expanded/rss_expanded_image_2_result_test_case.rs +++ b/src/oned/rss/expanded/rss_expanded_image_2_result_test_case.rs @@ -68,7 +68,7 @@ fn testDecodeRow2result2() { } fn assertCorrectImage2result(fileName: &str, expected: ExpandedProductParsedRXingResult) { - let path = format!("test_resources/blackbox/rssexpanded-1/{}", fileName); + let path = format!("test_resources/blackbox/rssexpanded-1/{fileName}"); let image = image::open(path).expect("image must exist"); let binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new( diff --git a/src/oned/rss/expanded/rss_expanded_image_2_string_test_case.rs b/src/oned/rss/expanded/rss_expanded_image_2_string_test_case.rs index daf64df..27becda 100644 --- a/src/oned/rss/expanded/rss_expanded_image_2_string_test_case.rs +++ b/src/oned/rss/expanded/rss_expanded_image_2_string_test_case.rs @@ -181,7 +181,7 @@ fn testDecodeRow2string32() { } fn assertCorrectImage2string(fileName: &str, expected: &str) { - let path = format!("test_resources/blackbox/rssexpanded-1/{}", fileName); + let path = format!("test_resources/blackbox/rssexpanded-1/{fileName}"); let image = image::open(path).expect("load image"); let binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new( diff --git a/src/oned/rss/expanded/rss_expanded_internal_test_case.rs b/src/oned/rss/expanded/rss_expanded_internal_test_case.rs index 4245f95..8680710 100644 --- a/src/oned/rss/expanded/rss_expanded_internal_test_case.rs +++ b/src/oned/rss/expanded/rss_expanded_internal_test_case.rs @@ -172,8 +172,7 @@ fn testDecodeDataCharacter() { fn readImage(fileName: &str) -> image::DynamicImage { image::open(format!( - "test_resources/blackbox/rssexpanded-1/{}", - fileName + "test_resources/blackbox/rssexpanded-1/{fileName}" )) .unwrap() // Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); diff --git a/src/oned/rss/expanded/test_case_util.rs b/src/oned/rss/expanded/test_case_util.rs index cff4a61..989c0b3 100644 --- a/src/oned/rss/expanded/test_case_util.rs +++ b/src/oned/rss/expanded/test_case_util.rs @@ -31,7 +31,7 @@ use image::DynamicImage; use crate::{common::GlobalHistogramBinarizer, BinaryBitmap, BufferedImageLuminanceSource}; fn getBufferedImage(fileName: &str) -> DynamicImage { - let path = format!("test_resources/blackbox/rssexpandedstacked-2/{}", fileName); + let path = format!("test_resources/blackbox/rssexpandedstacked-2/{fileName}"); image::open(path).expect("load image") } diff --git a/src/oned/upc_a_writer.rs b/src/oned/upc_a_writer.rs index dd486d3..339dd35 100644 --- a/src/oned/upc_a_writer.rs +++ b/src/oned/upc_a_writer.rs @@ -49,13 +49,12 @@ impl Writer for UPCAWriter { ) -> Result { if format != &BarcodeFormat::UPC_A { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Can only encode UPC-A, but got {:?}", - format + "Can only encode UPC-A, but got {format:?}" )))); } // Transform a UPC-A code into the equivalent EAN-13 code and write it that way self.0.encode_with_hints( - &format!("0{}", contents), + &format!("0{contents}"), &BarcodeFormat::EAN_13, width, height, diff --git a/src/oned/upc_e_writer.rs b/src/oned/upc_e_writer.rs index 671a0dd..c3f720f 100644 --- a/src/oned/upc_e_writer.rs +++ b/src/oned/upc_e_writer.rs @@ -69,8 +69,7 @@ impl OneDimensionalCodeWriter for UPCEWriter { // }}, _ => { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Requested contents should be 7 or 8 digits long, but got {}", - length + "Requested contents should be 7 or 8 digits long, but got {length}" )))) } } diff --git a/src/oned/upc_ean_extension_5_support.rs b/src/oned/upc_ean_extension_5_support.rs index e604c51..2a61b9c 100644 --- a/src/oned/upc_ean_extension_5_support.rs +++ b/src/oned/upc_ean_extension_5_support.rs @@ -209,11 +209,11 @@ impl UPCEANExtension5Support { let unitsString = (rawAmount / 100).to_string(); let hundredths = rawAmount % 100; let hundredthsString = if hundredths < 10 { - format!("0{}", hundredths) + format!("0{hundredths}") } else { hundredths.to_string() }; - Some(format!("{}{}.{}", currency, unitsString, hundredthsString)) + Some(format!("{currency}{unitsString}.{hundredthsString}")) } } diff --git a/src/oned/upc_ean_reader.rs b/src/oned/upc_ean_reader.rs index 52ca523..719e50a 100644 --- a/src/oned/upc_ean_reader.rs +++ b/src/oned/upc_ean_reader.rs @@ -304,7 +304,7 @@ pub trait UPCEANReader: OneDReader { decodeRXingResult.putMetadata( RXingResultMetadataType::SYMBOLOGY_IDENTIFIER, - RXingResultMetadataValue::SymbologyIdentifier(format!("]E{}", symbologyIdentifier)), + RXingResultMetadataValue::SymbologyIdentifier(format!("]E{symbologyIdentifier}")), ); Ok(decodeRXingResult) diff --git a/src/pdf417/decoder/detection_result.rs b/src/pdf417/decoder/detection_result.rs index 0d9518d..d68c14b 100644 --- a/src/pdf417/decoder/detection_result.rs +++ b/src/pdf417/decoder/detection_result.rs @@ -652,7 +652,7 @@ impl Display for DetectionRXingResult { // try (Formatter formatter = new Formatter()) { for codewordsRow in 0..rowIndicatorColumn.as_ref().unwrap().getCodewords().len() { // for (int codewordsRow = 0; codewordsRow < rowIndicatorColumn.getCodewords().length; codewordsRow++) { - write!(f, "CW {0:3}", codewordsRow)?; + write!(f, "CW {codewordsRow:3}")?; // formatter.format("CW %3d:", codewordsRow); for barcodeColumn in 0..self.barcodeColumnCount + 2 { // for (int barcodeColumn = 0; barcodeColumn < barcodeColumnCount + 2; barcodeColumn++) { diff --git a/src/pdf417/decoder/detection_result_column.rs b/src/pdf417/decoder/detection_result_column.rs index e134a39..606b5b6 100644 --- a/src/pdf417/decoder/detection_result_column.rs +++ b/src/pdf417/decoder/detection_result_column.rs @@ -133,7 +133,7 @@ impl Display for DetectionRXingResultColumn { for codeword in &self.codewords { // for (Codeword codeword : codewords) { if codeword.is_none() { - writeln!(f, "{:3}: | ", row)?; + writeln!(f, "{row:3}: | ")?; row += 1; continue; } diff --git a/src/pdf417/encoder/compaction.rs b/src/pdf417/encoder/compaction.rs index 235ad01..4f4b24f 100644 --- a/src/pdf417/encoder/compaction.rs +++ b/src/pdf417/encoder/compaction.rs @@ -41,8 +41,7 @@ impl TryFrom<&String> for Compaction { } } Err(Exceptions::FormatException(Some(format!( - "Compaction must be 0-3 (inclusivie). Found: {}", - value + "Compaction must be 0-3 (inclusivie). Found: {value}" )))) } } diff --git a/src/pdf417/encoder/pdf_417.rs b/src/pdf417/encoder/pdf_417.rs index 2530f05..c093283 100644 --- a/src/pdf417/encoder/pdf_417.rs +++ b/src/pdf417/encoder/pdf_417.rs @@ -247,7 +247,7 @@ impl PDF417 { //4. step: low-level encoding let mut barcode_matrix = BarcodeMatrix::new(rows as usize, cols as usize); self.encodeLowLevel( - &format!("{}{}", dataCodewords, ec), + &format!("{dataCodewords}{ec}"), cols, rows, errorCorrectionLevel, diff --git a/src/pdf417/encoder/pdf_417_high_level_encoder.rs b/src/pdf417/encoder/pdf_417_high_level_encoder.rs index dbb09dd..a5b9971 100644 --- a/src/pdf417/encoder/pdf_417_high_level_encoder.rs +++ b/src/pdf417/encoder/pdf_417_high_level_encoder.rs @@ -806,8 +806,7 @@ fn encodingECI(eci: i32, sb: &mut String) -> Result<(), Exceptions> { sb.push(char::from_u32((810900 - eci) as u32).unwrap()); } else { return Err(Exceptions::WriterException(Some(format!( - "ECI number not in valid range from 0..811799, but was {}", - eci + "ECI number not in valid range from 0..811799, but was {eci}" )))); } Ok(()) diff --git a/src/pdf417/pdf_417_writer.rs b/src/pdf417/pdf_417_writer.rs index 7bb47ec..36d97a5 100644 --- a/src/pdf417/pdf_417_writer.rs +++ b/src/pdf417/pdf_417_writer.rs @@ -60,8 +60,7 @@ impl Writer for PDF417Writer { ) -> Result { if format != &BarcodeFormat::PDF_417 { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Can only encode PDF_417, but got {}", - format + "Can only encode PDF_417, but got {format}" )))); } diff --git a/src/planar_yuv_luminance_source.rs b/src/planar_yuv_luminance_source.rs index 2258546..7327e62 100644 --- a/src/planar_yuv_luminance_source.rs +++ b/src/planar_yuv_luminance_source.rs @@ -252,7 +252,7 @@ impl LuminanceSource for PlanarYUVLuminanceSource { fn getRow(&self, y: usize) -> Vec { if y >= self.getHeight() { //throw new IllegalArgumentException("Requested row is outside the image: " + y); - panic!("Requested row is outside the image: {}", y); + panic!("Requested row is outside the image: {y}"); } let width = self.getWidth(); diff --git a/src/qrcode/decoder/bit_matrix_parser.rs b/src/qrcode/decoder/bit_matrix_parser.rs index 27a6e17..1538b0a 100644 --- a/src/qrcode/decoder/bit_matrix_parser.rs +++ b/src/qrcode/decoder/bit_matrix_parser.rs @@ -37,8 +37,7 @@ impl BitMatrixParser { let dimension = bit_matrix.getHeight(); if dimension < 21 || (dimension & 0x03) != 1 { Err(Exceptions::FormatException(Some(format!( - "{} < 21 || ({} % 0x03) != 1", - dimension, dimension + "{dimension} < 21 || ({dimension} % 0x03) != 1" )))) } else { Ok(Self { diff --git a/src/qrcode/decoder/data_mask.rs b/src/qrcode/decoder/data_mask.rs index 7d60bbe..383e7e5 100755 --- a/src/qrcode/decoder/data_mask.rs +++ b/src/qrcode/decoder/data_mask.rs @@ -231,8 +231,7 @@ impl TryFrom for DataMask { 6 => Ok(DataMask::DATA_MASK_110), 7 => Ok(DataMask::DATA_MASK_111), _ => Err(Exceptions::IllegalArgumentException(Some(format!( - "{} is not between 0 and 7", - value + "{value} is not between 0 and 7" )))), } } diff --git a/src/qrcode/decoder/data_mask_testcase.rs b/src/qrcode/decoder/data_mask_testcase.rs index a57496a..7cf1291 100644 --- a/src/qrcode/decoder/data_mask_testcase.rs +++ b/src/qrcode/decoder/data_mask_testcase.rs @@ -98,7 +98,7 @@ fn testMask(mask: DataMask, dimension: u32, condition: MaskCondition) { // for (int i = 0; i < dimension; i++) { for j in 0..dimension { // for (int j = 0; j < dimension; j++) { - assert_eq!(condition(i, j), bits.get(j, i), "({},{})", i, j); + assert_eq!(condition(i, j), bits.get(j, i), "({i},{j})"); } } } diff --git a/src/qrcode/decoder/decoded_bit_stream_parser.rs b/src/qrcode/decoder/decoded_bit_stream_parser.rs index 805ff83..905d2a0 100644 --- a/src/qrcode/decoder/decoded_bit_stream_parser.rs +++ b/src/qrcode/decoder/decoded_bit_stream_parser.rs @@ -96,8 +96,7 @@ pub fn decode( currentCharacterSetECI = Some(CharacterSetECI::getCharacterSetECIByValue(value)?); if currentCharacterSetECI.is_none() { return Err(Exceptions::FormatException(Some(format!( - "Value of {} not valid", - value + "Value of {value} not valid" )))); } } diff --git a/src/qrcode/decoder/error_correction_level.rs b/src/qrcode/decoder/error_correction_level.rs index 55a8651..0c9ebd5 100644 --- a/src/qrcode/decoder/error_correction_level.rs +++ b/src/qrcode/decoder/error_correction_level.rs @@ -48,8 +48,7 @@ impl ErrorCorrectionLevel { 2 => Ok(Self::H), 3 => Ok(Self::Q), _ => Err(Exceptions::IllegalArgumentException(Some(format!( - "{} is not a valid bit selection", - bits + "{bits} is not a valid bit selection" )))), } } @@ -111,8 +110,7 @@ impl FromStr for ErrorCorrectionLevel { } return Err(Exceptions::IllegalArgumentException(Some(format!( - "could not parse {} into an ec level", - s + "could not parse {s} into an ec level" )))); } } diff --git a/src/qrcode/decoder/mode.rs b/src/qrcode/decoder/mode.rs index b344916..1d927ae 100644 --- a/src/qrcode/decoder/mode.rs +++ b/src/qrcode/decoder/mode.rs @@ -69,8 +69,7 @@ impl Mode { Ok(Self::HANZI) } _ => Err(Exceptions::IllegalArgumentException(Some(format!( - "{} is not valid", - bits + "{bits} is not valid" )))), } } diff --git a/src/qrcode/encoder/byte_matrix.rs b/src/qrcode/encoder/byte_matrix.rs index 7cc9c4a..b7514e9 100644 --- a/src/qrcode/encoder/byte_matrix.rs +++ b/src/qrcode/encoder/byte_matrix.rs @@ -110,7 +110,7 @@ impl fmt::Display for ByteMatrix { } result.push('\n'); } - write!(f, "{}", result) + write!(f, "{result}") } } diff --git a/src/qrcode/encoder/mask_util.rs b/src/qrcode/encoder/mask_util.rs index 1b18180..077ce5b 100644 --- a/src/qrcode/encoder/mask_util.rs +++ b/src/qrcode/encoder/mask_util.rs @@ -186,8 +186,7 @@ pub fn getDataMaskBit(maskPattern: u32, x: u32, y: u32) -> Result { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Invalid mask pattern: {}", - maskPattern + "Invalid mask pattern: {maskPattern}" )))) } }; diff --git a/src/qrcode/encoder/minimal_encoder.rs b/src/qrcode/encoder/minimal_encoder.rs index d8b4d30..1e0af27 100644 --- a/src/qrcode/encoder/minimal_encoder.rs +++ b/src/qrcode/encoder/minimal_encoder.rs @@ -161,8 +161,7 @@ impl MinimalEncoder { &self.ecLevel, ) { return Err(Exceptions::WriterException(Some(format!( - "Data too big for version {}", - version + "Data too big for version {version}" )))); } Ok(result) @@ -270,8 +269,7 @@ impl MinimalEncoder { Mode::BYTE => Ok(3), Mode::KANJI => Ok(0), _ => Err(Exceptions::IllegalArgumentException(Some(format!( - "Illegal mode {:?}", - mode + "Illegal mode {mode:?}" )))), } // switch (mode) { @@ -956,7 +954,7 @@ impl fmt::Display for RXingResultList { result.push_str(¤t.to_string()); previous = Some(current); } - write!(f, "{}", result) + write!(f, "{result}") } } @@ -1141,6 +1139,6 @@ impl fmt::Display for RXingResultNode { } result.push(')'); - write!(f, "{}", result) + write!(f, "{result}") } } diff --git a/src/qrcode/encoder/qr_code.rs b/src/qrcode/encoder/qr_code.rs index 121b14f..3b52549 100644 --- a/src/qrcode/encoder/qr_code.rs +++ b/src/qrcode/encoder/qr_code.rs @@ -134,7 +134,7 @@ impl fmt::Display for QRCode { } result.push_str(">>\n"); - write!(f, "{}", result) + write!(f, "{result}") } } diff --git a/src/qrcode/encoder/qrcode_encoder.rs b/src/qrcode/encoder/qrcode_encoder.rs index 95593a1..ec04dd0 100644 --- a/src/qrcode/encoder/qrcode_encoder.rs +++ b/src/qrcode/encoder/qrcode_encoder.rs @@ -430,8 +430,7 @@ pub fn terminateBits(num_data_bytes: u32, bits: &mut BitArray) -> Result<(), Exc let capacity = num_data_bytes * 8; if bits.getSize() > capacity as usize { return Err(Exceptions::WriterException(Some(format!( - "data bits cannot fit in the QR Code{} > ", - capacity + "data bits cannot fit in the QR Code{capacity} > " )))); // throw new WriterException("data bits cannot fit in the QR Code" + bits.getSize() + " > " + // capacity); @@ -701,8 +700,7 @@ pub fn appendBytes( Mode::BYTE => append8BitBytes(content, bits, encoding), Mode::KANJI => appendKanjiBytes(content, bits), _ => Err(Exceptions::WriterException(Some(format!( - "Invalid mode: {:?}", - mode + "Invalid mode: {mode:?}" )))), } // switch (mode) { diff --git a/src/qrcode/qr_code_writer.rs b/src/qrcode/qr_code_writer.rs index 0e3a736..6514cab 100644 --- a/src/qrcode/qr_code_writer.rs +++ b/src/qrcode/qr_code_writer.rs @@ -66,16 +66,14 @@ impl Writer for QRCodeWriter { if format != &BarcodeFormat::QR_CODE { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Can only encode QR_CODE, but got {:?}", - format + "Can only encode QR_CODE, but got {format:?}" )))); // throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format); } if width < 0 || height < 0 { return Err(Exceptions::IllegalArgumentException(Some(format!( - "Requested dimensions are too small: {}x{}", - width, height + "Requested dimensions are too small: {width}x{height}" )))); // throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + // height); diff --git a/src/rgb_luminance_source.rs b/src/rgb_luminance_source.rs index 59aa994..8487b40 100644 --- a/src/rgb_luminance_source.rs +++ b/src/rgb_luminance_source.rs @@ -40,7 +40,7 @@ pub struct RGBLuminanceSource { impl LuminanceSource for RGBLuminanceSource { fn getRow(&self, y: usize) -> Vec { if y >= self.getHeight() { - panic!("Requested row is outside the image: {}", y); + panic!("Requested row is outside the image: {y}"); } let width = self.getWidth(); diff --git a/tests/common/abstract_black_box_test_case.rs b/tests/common/abstract_black_box_test_case.rs index 9b4900e..8f9cda0 100644 --- a/tests/common/abstract_black_box_test_case.rs +++ b/tests/common/abstract_black_box_test_case.rs @@ -263,7 +263,7 @@ impl AbstractBlackBoxTestCase { misread_counts[x] += 1; } } else { - log::fine(format!("could not read at rotation {}", rotation)); + log::fine(format!("could not read at rotation {rotation}")); } // try { // if (decode(bitmap, rotation, expectedText, expectedMetadata, false)) { @@ -287,7 +287,7 @@ impl AbstractBlackBoxTestCase { try_harder_misread_counts[x] += 1; } } else { - log::fine(format!("could not read at rotation {} w/TH", rotation)); + log::fine(format!("could not read at rotation {rotation} w/TH")); } // try { // if (decode(bitmap, rotation, expectedText, expectedMetadata, true)) { @@ -393,8 +393,7 @@ impl AbstractBlackBoxTestCase { ); assert!( try_harder_counts[x] >= test_rxing_result.get_try_harder_count() as usize, - "Try harder, {}", - label, + "Try harder, {label}", ); let label = format!( "Rotation {} degrees: Too many images misread", @@ -408,8 +407,7 @@ impl AbstractBlackBoxTestCase { assert!( try_harder_misread_counts[x] <= test_rxing_result.get_max_try_harder_misreads() as usize, - "Try harder, {}", - label + "Try harder, {label}" ); } } @@ -468,8 +466,7 @@ impl AbstractBlackBoxTestCase { let result_text = result.getText(); if expected_text != result_text { log::info(format!( - "Content mismatch: expected '{}' but got '{}'{}", - expected_text, result_text, suffix + "Content mismatch: expected '{expected_text}' but got '{result_text}'{suffix}" )); return Ok(false); } @@ -481,8 +478,7 @@ impl AbstractBlackBoxTestCase { let actual_value = result_metadata.get(key); if actual_value.is_none() || !(value == actual_value.unwrap()) { log::info(format!( - "Metadata mismatch for key '{:?}': expected '{:?}' but got '{:?}'", - key, value, actual_value + "Metadata mismatch for key '{key:?}': expected '{value:?}' but got '{actual_value:?}'" )); return Ok(false); } @@ -607,6 +603,6 @@ mod log { } fn prn(level: &str, data: String) { - println!("{} :: {}", level, data) + println!("{level} :: {data}") } } diff --git a/tests/common/pdf_417_multiimage_span.rs b/tests/common/pdf_417_multiimage_span.rs index 6b27875..5e2f600 100644 --- a/tests/common/pdf_417_multiimage_span.rs +++ b/tests/common/pdf_417_multiimage_span.rs @@ -149,7 +149,7 @@ impl PDF417MultiImageSpanAbstractBlackBoxTest for (name, files) in &image_files { // for (Entry> testImageGroup : imageFiles.entrySet()) { - log::fine(format!("Starting Image Group {}", name)); + log::fine(format!("Starting Image Group {name}")); let file_base_name = name; //testImageGroup.getKey(); // let expectedText : String; @@ -408,7 +408,7 @@ impl PDF417MultiImageSpanAbstractBlackBoxTest misread_counts[x] += 1; } } else { - log::fine(format!("could not read at rotation {}", rotation)); + log::fine(format!("could not read at rotation {rotation}")); } // try { // if (decode(bitmap, rotation, expectedText, expectedMetadata, false)) { @@ -432,7 +432,7 @@ impl PDF417MultiImageSpanAbstractBlackBoxTest try_harder_misread_counts[x] += 1; } } else { - log::fine(format!("could not read at rotation {} w/TH", rotation)); + log::fine(format!("could not read at rotation {rotation} w/TH")); } // try { // if (decode(bitmap, rotation, expectedText, expectedMetadata, true)) { @@ -538,8 +538,7 @@ impl PDF417MultiImageSpanAbstractBlackBoxTest ); assert!( try_harder_counts[x] >= test_rxing_result.get_try_harder_count() as usize, - "Try harder, {}", - label, + "Try harder, {label}", ); let label = format!( "Rotation {} degrees: Too many images misread", @@ -553,8 +552,7 @@ impl PDF417MultiImageSpanAbstractBlackBoxTest assert!( try_harder_misread_counts[x] <= test_rxing_result.get_max_try_harder_misreads() as usize, - "Try harder, {}", - label + "Try harder, {label}" ); } } @@ -613,8 +611,7 @@ impl PDF417MultiImageSpanAbstractBlackBoxTest let result_text = result.getText(); if expected_text != result_text { log::info(format!( - "Content mismatch: expected '{}' but got '{}'{}", - expected_text, result_text, suffix + "Content mismatch: expected '{expected_text}' but got '{result_text}'{suffix}" )); return Ok(false); } @@ -626,8 +623,7 @@ impl PDF417MultiImageSpanAbstractBlackBoxTest let actual_value = result_metadata.get(key); if actual_value.is_none() || !(value == actual_value.unwrap()) { log::info(format!( - "Metadata mismatch for key '{:?}': expected '{:?}' but got '{:?}'", - key, value, actual_value + "Metadata mismatch for key '{key:?}': expected '{value:?}' but got '{actual_value:?}'" )); return Ok(false); } @@ -804,6 +800,6 @@ mod log { } fn prn(level: &str, data: String) { - println!("{} :: {}", level, data) + println!("{level} :: {data}") } }