mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
cargo clippy --fix
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -231,8 +231,7 @@ impl TryFrom<u8> 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"
|
||||
)))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +69,7 @@ impl Mode {
|
||||
Ok(Self::HANZI)
|
||||
}
|
||||
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"{} is not valid",
|
||||
bits
|
||||
"{bits} is not valid"
|
||||
)))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ impl fmt::Display for ByteMatrix {
|
||||
}
|
||||
result.push('\n');
|
||||
}
|
||||
write!(f, "{}", result)
|
||||
write!(f, "{result}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,8 +186,7 @@ pub fn getDataMaskBit(maskPattern: u32, x: u32, y: u32) -> Result<bool, Exceptio
|
||||
}
|
||||
_ => {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Invalid mask pattern: {}",
|
||||
maskPattern
|
||||
"Invalid mask pattern: {maskPattern}"
|
||||
))))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ impl fmt::Display for QRCode {
|
||||
}
|
||||
result.push_str(">>\n");
|
||||
|
||||
write!(f, "{}", result)
|
||||
write!(f, "{result}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user