cargo clippy --fix

This commit is contained in:
Henry Schimke
2023-01-27 15:24:24 -06:00
parent 58e6827e89
commit 42d40de755
86 changed files with 196 additions and 335 deletions

View File

@@ -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}"
);
}

View File

@@ -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(&copy, 3)).detect(false);

View File

@@ -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})"
);
}

View File

@@ -107,8 +107,7 @@ fn encode(
) -> Result<BitMatrix, Exceptions> {
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 {

View File

@@ -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;

View File

@@ -53,7 +53,7 @@ pub const WORD_SIZE: [u32; 33] = [
pub fn encode_simple(data: &str) -> Result<AztecCode, Exceptions> {
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<GenericGFRef, Exceptions> {
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) {

View File

@@ -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