Skip to content

Commit 42d40de

Browse files
committed
cargo clippy --fix
1 parent 58e6827 commit 42d40de

File tree

86 files changed

+196
-335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+196
-335
lines changed

src/aztec/DecoderTest.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ fn test_high_level_decode_string(expectedString: &str, b: &str) {
7777
assert_eq!(
7878
expectedString,
7979
decoder::highLevelDecode(&toBooleanArray(&bits)).expect("highLevelDecode Failed"),
80-
"highLevelDecode() failed for input bits: {}",
81-
b
80+
"highLevelDecode() failed for input bits: {b}"
8281
);
8382
}
8483

src/aztec/DetectorTest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn test_error_in_parameter_locator_compact() {
6464
#[test]
6565
fn test_error_in_parameter_locator_not_compact() {
6666
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxyz";
67-
test_error_in_parameter_locator(&format!("{}{}{}", alphabet, alphabet, alphabet));
67+
test_error_in_parameter_locator(&format!("{alphabet}{alphabet}{alphabet}"));
6868
}
6969

7070
#[test]
@@ -165,7 +165,7 @@ fn test_error_in_parameter_locator(data: &str) {
165165
if let Exceptions::NotFoundException(_msg) = res {
166166
// all ok
167167
} else {
168-
panic!("Only Exceptions::NotFoundException allowed, got {}", res);
168+
panic!("Only Exceptions::NotFoundException allowed, got {res}");
169169
}
170170
} else {
171171
let r = Detector::new(&make_larger(&copy, 3)).detect(false);

src/aztec/EncoderTest.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ fn testBorderCompact4CaseFailed() {
617617
// be error correction
618618
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
619619
// encodes as 26 * 5 * 4 = 520 bits of data
620-
let alphabet4 = format!("{}{}{}{}", alphabet, alphabet, alphabet, alphabet);
620+
let alphabet4 = format!("{alphabet}{alphabet}{alphabet}{alphabet}");
621621
aztec_encoder::encode(&alphabet4, 0, -4).expect("encode");
622622
}
623623

@@ -627,7 +627,7 @@ fn testBorderCompact4Case() {
627627
// be error correction
628628
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
629629
// encodes as 26 * 5 * 4 = 520 bits of data
630-
let alphabet4 = format!("{}{}{}{}", alphabet, alphabet, alphabet, alphabet);
630+
let alphabet4 = format!("{alphabet}{alphabet}{alphabet}{alphabet}");
631631

632632
// If we just try to encode it normally, it will go to a non-compact 4 layer
633633
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) {
658658

659659
// let mut xored = BitMatrix::parse_strings(&stripSpace(expected), "X ", " ").expect("should parse");
660660
// xored.xor(matrix).expect("should xor");
661-
assert_eq!(expected, matrix.to_string(), "encode({}) failed", data);
661+
assert_eq!(expected, matrix.to_string(), "encode({data}) failed");
662662
}
663663

664664
fn testEncodeDecode(data: &str, compact: bool, layers: u32) {
@@ -814,8 +814,7 @@ fn testStuffBits(wordSize: usize, bits: &str, expected: &str) {
814814
assert_eq!(
815815
stripSpace(expected),
816816
stripSpace(&stuffed.to_string()),
817-
"stuffBits() failed for input string: {}",
818-
bits
817+
"stuffBits() failed for input string: {bits}"
819818
);
820819
}
821820

@@ -838,8 +837,7 @@ fn testHighLevelEncodeStringUtf8(s: &str, expectedBits: &str) {
838837
assert_eq!(
839838
stripSpace(expectedBits),
840839
receivedBits,
841-
"highLevelEncode() failed for input string: {}",
842-
s
840+
"highLevelEncode() failed for input string: {s}"
843841
);
844842
}
845843

@@ -856,8 +854,7 @@ fn testHighLevelEncodeString(s: &str, expectedBits: &str) {
856854
assert_eq!(
857855
stripSpace(expectedBits),
858856
receivedBits,
859-
"highLevelEncode() failed for input string: {}",
860-
s
857+
"highLevelEncode() failed for input string: {s}"
861858
);
862859
assert_eq!(
863860
s,
@@ -888,7 +885,6 @@ fn testHighLevelEncodeStringCount(s: &str, expectedReceivedBits: u32) {
888885
// );
889886
assert_eq!(
890887
expectedReceivedBits as usize, receivedBitCount,
891-
"highLevelEncode() failed for input string: {} with byte count ({}!={})",
892-
s, expectedReceivedBits, receivedBitCount
888+
"highLevelEncode() failed for input string: {s} with byte count ({expectedReceivedBits}!={receivedBitCount})"
893889
);
894890
}

src/aztec/aztec_writer.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ fn encode(
107107
) -> Result<BitMatrix, Exceptions> {
108108
if format != BarcodeFormat::AZTEC {
109109
return Err(Exceptions::IllegalArgumentException(Some(format!(
110-
"can only encode AZTEC, but got {:?}",
111-
format
110+
"can only encode AZTEC, but got {format:?}"
112111
))));
113112
}
114113
let aztec = if let Some(cset) = charset {

src/aztec/decoder.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@ fn correct_bits(
350350
let num_codewords = rawbits.len() / codeword_size;
351351
if num_codewords < num_data_codewords as usize {
352352
return Err(Exceptions::FormatException(Some(format!(
353-
"numCodewords {}< numDataCodewords{}",
354-
num_codewords, num_data_codewords
353+
"numCodewords {num_codewords}< numDataCodewords{num_data_codewords}"
355354
))));
356355
}
357356
let mut offset = rawbits.len() % codeword_size;

src/aztec/encoder/aztec_encoder.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub const WORD_SIZE: [u32; 33] = [
5353
pub fn encode_simple(data: &str) -> Result<AztecCode, Exceptions> {
5454
let Ok(bytes) = encoding::all::ISO_8859_1
5555
.encode(data, encoding::EncoderTrap::Replace) else {
56-
return Err(Exceptions::IllegalArgumentException(Some(format!("'{}' cannot be encoded as ISO_8859_1", data))));
56+
return Err(Exceptions::IllegalArgumentException(Some(format!("'{data}' cannot be encoded as ISO_8859_1"))));
5757
};
5858
encode_bytes_simple(&bytes)
5959
}
@@ -76,8 +76,7 @@ pub fn encode(
7676
encode_bytes(&bytes, minECCPercent, userSpecifiedLayers)
7777
} else {
7878
Err(Exceptions::IllegalArgumentException(Some(format!(
79-
"'{}' cannot be encoded as ISO_8859_1",
80-
data
79+
"'{data}' cannot be encoded as ISO_8859_1"
8180
))))
8281
}
8382
}
@@ -104,8 +103,7 @@ pub fn encode_with_charset(
104103
encode_bytes_with_charset(&bytes, minECCPercent, userSpecifiedLayers, charset)
105104
} else {
106105
Err(Exceptions::IllegalArgumentException(Some(format!(
107-
"'{}' cannot be encoded as ISO_8859_1",
108-
data
106+
"'{data}' cannot be encoded as ISO_8859_1"
109107
))))
110108
}
111109
}
@@ -181,8 +179,7 @@ pub fn encode_bytes_with_charset(
181179
})
182180
{
183181
return Err(Exceptions::IllegalArgumentException(Some(format!(
184-
"Illegal value {} for layers",
185-
user_specified_layers
182+
"Illegal value {user_specified_layers} for layers"
186183
))));
187184
}
188185
total_bits_in_layer_var = total_bits_in_layer(layers, compact);
@@ -498,8 +495,7 @@ fn getGF(wordSize: usize) -> Result<GenericGFRef, Exceptions> {
498495
10 => Ok(get_predefined_genericgf(PredefinedGenericGF::AztecData10)),
499496
12 => Ok(get_predefined_genericgf(PredefinedGenericGF::AztecData12)),
500497
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
501-
"Unsupported word size {}",
502-
wordSize
498+
"Unsupported word size {wordSize}"
503499
)))),
504500
}
505501
// switch (wordSize) {

src/aztec/encoder/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl State {
8686
// throw new IllegalArgumentException("ECI code must be between 0 and 999999");
8787
} else {
8888
let eci_digits = encoding::all::ISO_8859_1
89-
.encode(&format!("{}", eci), encoding::EncoderTrap::Strict)
89+
.encode(&format!("{eci}"), encoding::EncoderTrap::Strict)
9090
.unwrap();
9191
// let eciDigits = Integer.toString(eci).getBytes(StandardCharsets.ISO_8859_1);
9292
token.add(eci_digits.len() as i32, 3); // 1-6: number of ECI digits

src/client/result/AddressBookAUResultParser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn matchMultipleValuePrefix(prefix: &str, rawText: &str) -> Vec<String> {
8989
for i in 1..=3 {
9090
// for (int i = 1; i <= 3; i++) {
9191
let value = ResultParser::matchSinglePrefixedField(
92-
&format!("{}{}:", prefix, i),
92+
&format!("{prefix}{i}:"),
9393
rawText,
9494
'\r',
9595
true,

src/client/result/BizcardResultParser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ fn buildName(firstName: &str, lastName: &str) -> String {
123123
} else if lastName.is_empty() {
124124
firstName.to_owned()
125125
} else {
126-
format!("{} {}", firstName, lastName)
126+
format!("{firstName} {lastName}")
127127
}
128128
}

src/client/result/CalendarParsedResult.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ impl CalendarParsedRXingResult {
196196
return match Utc.datetime_from_str(&when, "%Y%m%dT%H%M%SZ") {
197197
Ok(dtm) => Ok(dtm.with_timezone(&Utc).timestamp()),
198198
Err(e) => Err(Exceptions::ParseException(Some(format!(
199-
"couldn't parse string: {}",
200-
e
199+
"couldn't parse string: {e}"
201200
)))),
202201
};
203202
// let dtm = DateTime::parse_from_str(&when, "%Y%m%dT%H%M%S").unwrap().with_timezone(&Utc);
@@ -219,16 +218,14 @@ impl CalendarParsedRXingResult {
219218
Ok(time_zone) => time_zone,
220219
Err(e) => {
221220
return Err(Exceptions::ParseException(Some(format!(
222-
"couldn't parse timezone '{}': {}",
223-
tz_part, e
221+
"couldn't parse timezone '{tz_part}': {e}"
224222
))))
225223
}
226224
};
227225
return match Utc.datetime_from_str(time_part, "%Y%m%dT%H%M%S") {
228226
Ok(dtm) => Ok(dtm.with_timezone(&tz_parsed).timestamp()),
229227
Err(e) => Err(Exceptions::ParseException(Some(format!(
230-
"couldn't parse string: {}",
231-
e
228+
"couldn't parse string: {e}"
232229
)))),
233230
};
234231
}
@@ -238,8 +235,7 @@ impl CalendarParsedRXingResult {
238235
return match Utc.datetime_from_str(&when, "%Y%m%dT%H%M%S") {
239236
Ok(dtm) => Ok(dtm.timestamp()),
240237
Err(e) => Err(Exceptions::ParseException(Some(format!(
241-
"couldn't parse local time: {}",
242-
e
238+
"couldn't parse local time: {e}"
243239
)))),
244240
};
245241
}
@@ -300,8 +296,7 @@ impl CalendarParsedRXingResult {
300296
Ok(dtm.timestamp())
301297
} else {
302298
Err(Exceptions::ParseException(Some(format!(
303-
"Couldn't parse {}",
304-
dateTimeString
299+
"Couldn't parse {dateTimeString}"
305300
))))
306301
}
307302
// DateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.ENGLISH);

src/client/result/ExpandedProductParsedResultTestCase.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn testRSSExpanded() {
7878
let ev = epr_res.getUncommonAIs().get(k).unwrap();
7979
assert_eq!(v, ev);
8080
} else {
81-
panic!("key not found {}", k)
81+
panic!("key not found {k}")
8282
}
8383
}
8484
// assert_eq!(&uncommonAIs, epr_res.getUncommonAIs());

src/client/result/TelParsedResultTestCase.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn doTest(contents: &str, number: &str, title: &str) {
4949
if let ParsedClientResult::TelResult(telRXingResult) = result {
5050
assert_eq!(number, telRXingResult.getNumber());
5151
assert_eq!(title, telRXingResult.getTitle());
52-
assert_eq!(format!("tel:{}", number), telRXingResult.getTelURI());
52+
assert_eq!(format!("tel:{number}"), telRXingResult.getTelURI());
5353
} else {
5454
panic!("wrong return type, expected TelResult");
5555
}

src/client/result/TelResultParser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<ParsedClientResult>
3636
}
3737
// Normalize "TEL:" to "tel:"
3838
let telURI = if let Some(stripped) = rawText.strip_prefix("TEL:") {
39-
format!("tel:{}", stripped)
39+
format!("tel:{stripped}")
4040
} else {
4141
rawText.clone()
4242
};

src/client/result/VCardResultParser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub fn matchVCardPrefixedField(
182182

183183
// At start or after newline, match prefix, followed by optional metadata
184184
// (led by ;) ultimately ending in colon
185-
let matcher_primary = Regex::new(&format!("(?:^|\\n)(?i:{})(?:;([^:]*))?:", prefix)).unwrap();
185+
let matcher_primary = Regex::new(&format!("(?:^|\\n)(?i:{prefix})(?:;([^:]*))?:")).unwrap();
186186
// let matcher_primary = Regex::new(&format!("(?:^|\n){}(.*)", prefix)).unwrap();
187187

188188
//let lower_case_raw_text = rawText.to_lowercase();

src/client/result/VEventResultParser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn matchSingleVCardPrefixedField(prefix: &str, rawText: &str) -> String {
134134
"".to_owned()
135135
};
136136
let root_time = values.last().unwrap().clone();
137-
format!("{}{}", root_time, tz_mod)
137+
format!("{root_time}{tz_mod}")
138138
}
139139
} else {
140140
"".to_owned()

src/common/BitArrayTestCase.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ fn test_get_next_set1() {
4545
let array = BitArray::with_size(32);
4646
for i in 0..array.getSize() {
4747
// for (int i = 0; i < array.getSize(); i++) {
48-
assert_eq!(32, array.getNextSet(i), "{}", i);
48+
assert_eq!(32, array.getNextSet(i), "{i}");
4949
}
5050
let array = BitArray::with_size(33);
5151
for i in 0..array.getSize() {
5252
// for (int i = 0; i < array.getSize(); i++) {
53-
assert_eq!(33, array.getNextSet(i), "{}", i);
53+
assert_eq!(33, array.getNextSet(i), "{i}");
5454
}
5555
}
5656

@@ -60,13 +60,13 @@ fn test_get_next_set2() {
6060
array.set(31);
6161
for i in 0..array.getSize() {
6262
// for (int i = 0; i < array.getSize(); i++) {
63-
assert_eq!(if i <= 31 { 31 } else { 33 }, array.getNextSet(i), "{}", i);
63+
assert_eq!(if i <= 31 { 31 } else { 33 }, array.getNextSet(i), "{i}");
6464
}
6565
array = BitArray::with_size(33);
6666
array.set(32);
6767
for i in 0..array.getSize() {
6868
// for (int i = 0; i < array.getSize(); i++) {
69-
assert_eq!(32, array.getNextSet(i), "{}", i);
69+
assert_eq!(32, array.getNextSet(i), "{i}");
7070
}
7171
}
7272

@@ -85,7 +85,7 @@ fn test_get_next_set3() {
8585
} else {
8686
expected = 63;
8787
}
88-
assert_eq!(expected, array.getNextSet(i), "{}", i);
88+
assert_eq!(expected, array.getNextSet(i), "{i}");
8989
}
9090
}
9191

@@ -104,7 +104,7 @@ fn test_get_next_set4() {
104104
} else {
105105
expected = 63;
106106
}
107-
assert_eq!(expected, array.getNextSet(i), "{}", i);
107+
assert_eq!(expected, array.getNextSet(i), "{i}");
108108
}
109109
}
110110

src/common/bit_array.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ impl fmt::Display for BitArray {
393393
}
394394
_str.push_str(if self.get(i) { "X" } else { "." });
395395
}
396-
write!(f, "{}", _str)
396+
write!(f, "{_str}")
397397
}
398398
}
399399

src/common/bit_matrix_test_case.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ fn test_rotate_180(width: u32, height: u32) {
367367
// for (int y = 0; y < height; y++) {
368368
for x in 0..width {
369369
// for (int x = 0; x < width; x++) {
370-
assert_eq!(expected.get(x, y), input.get(x, y), "({},{})", x, y);
370+
assert_eq!(expected.get(x, y), input.get(x, y), "({x},{y})");
371371
}
372372
}
373373
}

src/common/eci_string_builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl ECIStringBuilder {
9494
* @param value int to append as a string
9595
*/
9696
pub fn append(&mut self, value: i32) {
97-
self.append_string(&format!("{}", value));
97+
self.append_string(&format!("{value}"));
9898
}
9999

100100
/**

0 commit comments

Comments
 (0)