mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
warning cleanup
This commit is contained in:
@@ -33,7 +33,7 @@ impl SimpleToken {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn appendTo(&self, bit_array: &mut BitArray, text: &[u8]) {
|
||||
pub fn appendTo(&self, bit_array: &mut BitArray, _text: &[u8]) {
|
||||
bit_array
|
||||
.appendBits(self.value as u32, self.bit_count as usize)
|
||||
.expect("append should never fail");
|
||||
|
||||
@@ -474,7 +474,7 @@ impl BitArray {
|
||||
*/
|
||||
pub fn setRange(&mut self, start: usize, end: usize) -> Result<(), Exceptions> {
|
||||
let mut end = end;
|
||||
if end < start || start < 0 || end > self.size {
|
||||
if end < start || end > self.size {
|
||||
return Err(Exceptions::IllegalArgumentException(
|
||||
"end < start || start < 0 || end > self.size".to_owned(),
|
||||
));
|
||||
@@ -518,7 +518,7 @@ impl BitArray {
|
||||
*/
|
||||
pub fn isRange(&self, start: usize, end: usize, value: bool) -> Result<bool, Exceptions> {
|
||||
let mut end = end;
|
||||
if end < start || start < 0 || end > self.size {
|
||||
if end < start || end > self.size {
|
||||
return Err(Exceptions::IllegalArgumentException(
|
||||
"end < start || start < 0 || end > self.size".to_owned(),
|
||||
));
|
||||
@@ -1035,11 +1035,11 @@ impl BitMatrix {
|
||||
width: u32,
|
||||
height: u32,
|
||||
) -> Result<(), Exceptions> {
|
||||
if top < 0 || left < 0 {
|
||||
return Err(Exceptions::IllegalArgumentException(
|
||||
"Left and top must be nonnegative".to_owned(),
|
||||
));
|
||||
}
|
||||
// if top < 0 || left < 0 {
|
||||
// return Err(Exceptions::IllegalArgumentException(
|
||||
// "Left and top must be nonnegative".to_owned(),
|
||||
// ));
|
||||
// }
|
||||
if height < 1 || width < 1 {
|
||||
return Err(Exceptions::IllegalArgumentException(
|
||||
"Height and width must be at least 1".to_owned(),
|
||||
@@ -1133,7 +1133,7 @@ impl BitMatrix {
|
||||
pub fn rotate180(&mut self) {
|
||||
let mut topRow = BitArray::with_size(self.width as usize);
|
||||
let mut bottomRow = BitArray::with_size(self.width as usize);
|
||||
let mut maxHeight = (self.height + 1) / 2;
|
||||
let maxHeight = (self.height + 1) / 2;
|
||||
for i in 0..maxHeight {
|
||||
//for (int i = 0; i < maxHeight; i++) {
|
||||
topRow = self.getRow(i, &topRow);
|
||||
@@ -1150,9 +1150,9 @@ impl BitMatrix {
|
||||
* Modifies this {@code BitMatrix} to represent the same but rotated 90 degrees counterclockwise
|
||||
*/
|
||||
pub fn rotate90(&mut self) {
|
||||
let mut newWidth = self.height;
|
||||
let mut newHeight = self.width;
|
||||
let mut newRowSize = (newWidth + 31) / 32;
|
||||
let newWidth = self.height;
|
||||
let newHeight = self.width;
|
||||
let newRowSize = (newWidth + 31) / 32;
|
||||
let mut newBits = vec![0; (newRowSize * newHeight).try_into().unwrap()];
|
||||
|
||||
for y in 0..self.height {
|
||||
|
||||
@@ -1213,7 +1213,7 @@ pub mod result_point_utils {
|
||||
);
|
||||
|
||||
let mut pointA; //: &RXingResultPoint;
|
||||
let mut pointB; //: &RXingResultPoint;
|
||||
let pointB; //: &RXingResultPoint;
|
||||
let mut pointC; //: &RXingResultPoint;
|
||||
// Assume one closest to other two is B; A and C will just be guesses at first
|
||||
if oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance {
|
||||
|
||||
@@ -78,7 +78,7 @@ impl BitMatrixParser {
|
||||
// for (int x = 0; x < width; x++) {
|
||||
let bit = bitnrRow[x];
|
||||
if bit >= 0 && self.0.get(x as u32, y as u32) {
|
||||
result[bit as usize / 6] |= (1 << (5 - (bit % 6)));
|
||||
result[bit as usize / 6] |= 1 << (5 - (bit % 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,11 +64,11 @@ impl DataBlock {
|
||||
let ecBlocks = version.getECBlocksForLevel(ecLevel);
|
||||
|
||||
// First count the total number of data blocks
|
||||
let mut totalBlocks = 0;
|
||||
let mut _totalBlocks = 0;
|
||||
let ecBlockArray = ecBlocks.getECBlocks();
|
||||
for ecBlock in ecBlockArray {
|
||||
// for (Version.ECB ecBlock : ecBlockArray) {
|
||||
totalBlocks += ecBlock.getCount();
|
||||
_totalBlocks += ecBlock.getCount();
|
||||
}
|
||||
|
||||
// Now establish DataBlocks of the appropriate size and number of data codewords
|
||||
|
||||
@@ -36,7 +36,7 @@ use super::{decoded_bit_stream_parser, BitMatrixParser, DataBlock, QRCodeDecoder
|
||||
|
||||
lazy_static! {
|
||||
//rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256);
|
||||
static ref rsDecoder : ReedSolomonDecoder = ReedSolomonDecoder::new(get_predefined_genericgf(PredefinedGenericGF::QrCodeField256));
|
||||
static ref RS_DECODER : ReedSolomonDecoder = ReedSolomonDecoder::new(get_predefined_genericgf(PredefinedGenericGF::QrCodeField256));
|
||||
}
|
||||
|
||||
pub fn decode_bool_array(image: &Vec<Vec<bool>>) -> Result<DecoderRXingResult, Exceptions> {
|
||||
@@ -200,7 +200,7 @@ fn correctErrors(codewordBytes: &mut [u8], numDataCodewords: usize) -> Result<()
|
||||
|
||||
let mut sending_code_words : Vec<i32> = codewordsInts.iter().map(|x| *x as i32).collect();
|
||||
|
||||
if let Err(e) = rsDecoder.decode(
|
||||
if let Err(e) = RS_DECODER.decode(
|
||||
&mut sending_code_words,
|
||||
(codewordBytes.len() - numDataCodewords) as i32,
|
||||
) {
|
||||
|
||||
@@ -134,7 +134,7 @@ impl FormatInformation {
|
||||
if masked_format_info1 != masked_format_info2 {
|
||||
// also try the other option
|
||||
bits_difference = Self::numBitsDiffering(masked_format_info2, targetInfo);
|
||||
if (bits_difference < best_difference) {
|
||||
if bits_difference < best_difference {
|
||||
best_format_info = decodeInfo[1] as u8;
|
||||
best_difference = bits_difference;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ pub fn encode_with_hints(
|
||||
let encoding = if encoding.is_some() {
|
||||
encoding.unwrap()
|
||||
} else {
|
||||
if let Ok(encs) = DEFAULT_BYTE_MODE_ENCODING.encode(content, encoding::EncoderTrap::Strict){
|
||||
if let Ok(_encs) = DEFAULT_BYTE_MODE_ENCODING.encode(content, encoding::EncoderTrap::Strict){
|
||||
DEFAULT_BYTE_MODE_ENCODING
|
||||
}else {
|
||||
has_encoding_hint = true;
|
||||
|
||||
@@ -169,7 +169,7 @@ pub fn embedTypeInfo(
|
||||
matrix: &mut ByteMatrix,
|
||||
) -> Result<(), Exceptions> {
|
||||
let mut typeInfoBits = BitArray::new();
|
||||
makeTypeInfoBits(ecLevel, maskPattern as u32, &mut typeInfoBits);
|
||||
makeTypeInfoBits(ecLevel, maskPattern as u32, &mut typeInfoBits)?;
|
||||
|
||||
for i in 0..typeInfoBits.getSize() {
|
||||
// for (int i = 0; i < typeInfoBits.getSize(); ++i) {
|
||||
@@ -363,7 +363,7 @@ pub fn makeTypeInfoBits(
|
||||
|
||||
let mut maskBits = BitArray::new();
|
||||
maskBits.appendBits(TYPE_INFO_MASK_PATTERN, 15)?;
|
||||
bits.xor(&maskBits);
|
||||
bits.xor(&maskBits)?;
|
||||
|
||||
if bits.getSize() != 15 {
|
||||
// Just in case.
|
||||
|
||||
@@ -943,7 +943,7 @@ impl RXingResultList {
|
||||
*/
|
||||
pub fn getBits(&self, bits: &mut BitArray) -> Result<(), Exceptions> {
|
||||
for resultNode in &self.list {
|
||||
resultNode.getBits(bits);
|
||||
resultNode.getBits(bits)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -1078,19 +1078,19 @@ impl RXingResultNode {
|
||||
* appends the bits
|
||||
*/
|
||||
fn getBits(&self, bits: &mut BitArray) -> Result<(), Exceptions> {
|
||||
bits.appendBits(self.mode.getBits() as u32, 4);
|
||||
bits.appendBits(self.mode.getBits() as u32, 4)?;
|
||||
if self.characterLength > 0 {
|
||||
let length = self.getCharacterCountIndicator();
|
||||
bits.appendBits(
|
||||
length,
|
||||
self.mode.getCharacterCountBits(self.version) as usize,
|
||||
);
|
||||
)?;
|
||||
}
|
||||
if self.mode == Mode::ECI {
|
||||
bits.appendBits(
|
||||
self.encoders.getECIValue(self.charsetEncoderIndex as usize),
|
||||
8,
|
||||
);
|
||||
)?;
|
||||
} else if self.characterLength > 0 {
|
||||
// append data
|
||||
encoder::appendBytes(
|
||||
@@ -1100,7 +1100,7 @@ impl RXingResultNode {
|
||||
self.mode,
|
||||
bits,
|
||||
self.encoders.getCharset(self.charsetEncoderIndex as usize),
|
||||
);
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ impl Writer for QRCodeWriter {
|
||||
height: i32,
|
||||
hints: &crate::EncodingHintDictionary,
|
||||
) -> Result<crate::common::BitMatrix, crate::Exceptions> {
|
||||
if (contents.is_empty()) {
|
||||
if contents.is_empty() {
|
||||
return Err(Exceptions::IllegalArgumentException(
|
||||
"Found empty contents".to_owned(),
|
||||
));
|
||||
@@ -71,7 +71,7 @@ impl Writer for QRCodeWriter {
|
||||
// throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format);
|
||||
}
|
||||
|
||||
if (width < 0 || height < 0) {
|
||||
if width < 0 || height < 0 {
|
||||
return Err(Exceptions::IllegalArgumentException(format!(
|
||||
"Requested dimensions are too small: {}x{}",
|
||||
width, height
|
||||
@@ -158,7 +158,7 @@ impl QRCodeWriter {
|
||||
outputY as u32,
|
||||
multiple as u32,
|
||||
multiple as u32,
|
||||
);
|
||||
)?;
|
||||
}
|
||||
|
||||
inputX += 1;
|
||||
|
||||
Reference in New Issue
Block a user