clippy fix

This commit is contained in:
Henry
2023-01-04 18:29:08 -06:00
parent 7074daa94d
commit 9a5d6a704b
2 changed files with 14 additions and 22 deletions

View File

@@ -47,7 +47,7 @@ fn test_random() {
fn test_short_shift_jis1() { fn test_short_shift_jis1() {
// 金魚 // 金魚
do_test( do_test(
&vec![0x8b, 0xe0, 0x8b, 0x9b], &[0x8b, 0xe0, 0x8b, 0x9b],
encoding::label::encoding_from_whatwg_label("SJIS").unwrap(), encoding::label::encoding_from_whatwg_label("SJIS").unwrap(),
"SJIS", "SJIS",
); );
@@ -57,7 +57,7 @@ fn test_short_shift_jis1() {
fn test_short_iso885911() { fn test_short_iso885911() {
// båd // båd
do_test( do_test(
&vec![0x62, 0xe5, 0x64], &[0x62, 0xe5, 0x64],
encoding::all::ISO_8859_1, encoding::all::ISO_8859_1,
"ISO8859_1", "ISO8859_1",
); );
@@ -67,7 +67,7 @@ fn test_short_iso885911() {
fn test_short_utf8() { fn test_short_utf8() {
// Español // Español
do_test( do_test(
&vec![0x45, 0x73, 0x70, 0x61, 0xc3, 0xb1, 0x6f, 0x6c], &[0x45, 0x73, 0x70, 0x61, 0xc3, 0xb1, 0x6f, 0x6c],
encoding::all::UTF_8, encoding::all::UTF_8,
"UTF8", "UTF8",
); );
@@ -77,7 +77,7 @@ fn test_short_utf8() {
fn test_mixed_shift_jis1() { fn test_mixed_shift_jis1() {
// Hello 金! // Hello 金!
do_test( do_test(
&vec![0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x8b, 0xe0, 0x21], &[0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x8b, 0xe0, 0x21],
encoding::label::encoding_from_whatwg_label("SJIS").unwrap(), encoding::label::encoding_from_whatwg_label("SJIS").unwrap(),
"SJIS", "SJIS",
); );
@@ -87,7 +87,7 @@ fn test_mixed_shift_jis1() {
fn test_utf16_be() { fn test_utf16_be() {
// 调压柜 // 调压柜
do_test( do_test(
&vec![0xFE, 0xFF, 0x8c, 0x03, 0x53, 0x8b, 0x67, 0xdc], &[0xFE, 0xFF, 0x8c, 0x03, 0x53, 0x8b, 0x67, 0xdc],
encoding::all::UTF_16BE, encoding::all::UTF_16BE,
encoding::all::UTF_16BE.name(), encoding::all::UTF_16BE.name(),
); );
@@ -97,7 +97,7 @@ fn test_utf16_be() {
fn test_utf16_le() { fn test_utf16_le() {
// 调压柜 // 调压柜
do_test( do_test(
&vec![0xFF, 0xFE, 0x03, 0x8c, 0x8b, 0x53, 0xdc, 0x67], &[0xFF, 0xFE, 0x03, 0x8c, 0x8b, 0x53, 0xdc, 0x67],
encoding::all::UTF_16LE, encoding::all::UTF_16LE,
encoding::all::UTF_16LE.name(), encoding::all::UTF_16LE.name(),
); );

View File

@@ -36,15 +36,13 @@ pub fn detect_in_file_with_hints(
); );
} }
if !hints.contains_key(&DecodeHintType::TRY_HARDER) { hints.entry(DecodeHintType::TRY_HARDER).or_insert(DecodeHintValue::TryHarder(true));
hints.insert(DecodeHintType::TRY_HARDER, DecodeHintValue::TryHarder(true));
}
multi_format_reader.decode_with_hints( multi_format_reader.decode_with_hints(
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new( &mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
BufferedImageLuminanceSource::new(img), BufferedImageLuminanceSource::new(img),
))))), ))))),
&hints, hints,
) )
} }
@@ -62,15 +60,13 @@ pub fn detect_multiple_in_file_with_hints(
let multi_format_reader = MultiFormatReader::default(); let multi_format_reader = MultiFormatReader::default();
let mut scanner = GenericMultipleBarcodeReader::new(multi_format_reader); let mut scanner = GenericMultipleBarcodeReader::new(multi_format_reader);
if !hints.contains_key(&DecodeHintType::TRY_HARDER) { hints.entry(DecodeHintType::TRY_HARDER).or_insert(DecodeHintValue::TryHarder(true));
hints.insert(DecodeHintType::TRY_HARDER, DecodeHintValue::TryHarder(true));
}
scanner.decode_multiple_with_hints( scanner.decode_multiple_with_hints(
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new( &mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
BufferedImageLuminanceSource::new(img), BufferedImageLuminanceSource::new(img),
))))), ))))),
&hints, hints,
) )
} }
@@ -99,15 +95,13 @@ pub fn detect_in_luma_with_hints(
); );
} }
if !hints.contains_key(&DecodeHintType::TRY_HARDER) { hints.entry(DecodeHintType::TRY_HARDER).or_insert(DecodeHintValue::TryHarder(true));
hints.insert(DecodeHintType::TRY_HARDER, DecodeHintValue::TryHarder(true));
}
multi_format_reader.decode_with_hints( multi_format_reader.decode_with_hints(
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new( &mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
Luma8LuminanceSource::new(luma, width, height), Luma8LuminanceSource::new(luma, width, height),
))))), ))))),
&hints, hints,
) )
} }
@@ -128,14 +122,12 @@ pub fn detect_multiple_in_luma_with_hints(
let multi_format_reader = MultiFormatReader::default(); let multi_format_reader = MultiFormatReader::default();
let mut scanner = GenericMultipleBarcodeReader::new(multi_format_reader); let mut scanner = GenericMultipleBarcodeReader::new(multi_format_reader);
if !hints.contains_key(&DecodeHintType::TRY_HARDER) { hints.entry(DecodeHintType::TRY_HARDER).or_insert(DecodeHintValue::TryHarder(true));
hints.insert(DecodeHintType::TRY_HARDER, DecodeHintValue::TryHarder(true));
}
scanner.decode_multiple_with_hints( scanner.decode_multiple_with_hints(
&mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new( &mut BinaryBitmap::new(Rc::new(RefCell::new(HybridBinarizer::new(Box::new(
Luma8LuminanceSource::new(luma, width, height), Luma8LuminanceSource::new(luma, width, height),
))))), ))))),
&hints, hints,
) )
} }