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

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

View File

@@ -393,7 +393,7 @@ impl fmt::Display for BitArray {
}
_str.push_str(if self.get(i) { "X" } else { "." });
}
write!(f, "{}", _str)
write!(f, "{_str}")
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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