diff --git a/src/common/bit_matrix.rs b/src/common/bit_matrix.rs index d6c0d083..8d4b14cf 100644 --- a/src/common/bit_matrix.rs +++ b/src/common/bit_matrix.rs @@ -530,7 +530,7 @@ impl BitMatrix { if theBits != 0 { top = top.min(y); bottom = bottom.max(y); - + if x32 * 32 < left as usize { let mut bit = 0; while (theBits << (31 - bit)) == 0 { diff --git a/src/common/global_histogram_binarizer.rs b/src/common/global_histogram_binarizer.rs index bbb694cd..9d2f2c69 100644 --- a/src/common/global_histogram_binarizer.rs +++ b/src/common/global_histogram_binarizer.rs @@ -156,7 +156,7 @@ impl GlobalHistogramBinarizer { let row = height * y / 5; let localLuminances = source.get_row(row); let right = (width * 4) / 5; - for x in (width/5)..right { + for x in (width / 5)..right { let pixel = localLuminances[x]; localBuckets[(pixel >> LUMINANCE_SHIFT) as usize] += 1; } diff --git a/src/common/grid_sampler.rs b/src/common/grid_sampler.rs index 0a0d5190..b25e7110 100644 --- a/src/common/grid_sampler.rs +++ b/src/common/grid_sampler.rs @@ -172,12 +172,7 @@ pub trait GridSampler { } // dbg!(bits.to_string()); - Ok(( - bits, - [ - Point::default();4 - ], - )) + Ok((bits, [Point::default(); 4])) } /** diff --git a/src/common/hybrid_binarizer.rs b/src/common/hybrid_binarizer.rs index 2fa37acd..3723f169 100644 --- a/src/common/hybrid_binarizer.rs +++ b/src/common/hybrid_binarizer.rs @@ -170,11 +170,11 @@ impl HybridBinarizer { for y in 0..sub_height { // for (int y = 0; y < subHeight; y++) { let yoffset = u32::min(y << BLOCK_SIZE_POWER, maxYOffset); - + let top = Self::cap(y, sub_height - 3); for x in 0..sub_width { // for (int x = 0; x < subWidth; x++) { - let xoffset = u32::min(x << BLOCK_SIZE_POWER,maxXOffset); + let xoffset = u32::min(x << BLOCK_SIZE_POWER, maxXOffset); let left = Self::cap(x, sub_width - 3); let mut sum = 0; @@ -240,12 +240,12 @@ impl HybridBinarizer { let mut blackPoints = vec![vec![0; subWidth as usize]; subHeight as usize]; for y in 0..subHeight { // for (int y = 0; y < subHeight; y++) { - let yoffset = u32::min(y << BLOCK_SIZE_POWER,maxYOffset as u32); - + let yoffset = u32::min(y << BLOCK_SIZE_POWER, maxYOffset as u32); + for x in 0..subWidth { // for (int x = 0; x < subWidth; x++) { - let xoffset = u32::min(x << BLOCK_SIZE_POWER,maxXOffset as u32); - + let xoffset = u32::min(x << BLOCK_SIZE_POWER, maxXOffset as u32); + let mut sum: u32 = 0; let mut min = 0xff; let mut max = 0; diff --git a/src/common/string_utils.rs b/src/common/string_utils.rs index 5b12ac36..f13d968b 100644 --- a/src/common/string_utils.rs +++ b/src/common/string_utils.rs @@ -92,11 +92,9 @@ impl StringUtils { } // First try UTF-16, assuming anything with its BOM is UTF-16 - - if bytes.len() > 2 - && ((bytes[0..=1] == [0xFE,0xFF]) || (bytes[0..=1] == [0xFF , 0xFE])) - { - if bytes[0..=1] == [0xFE , 0xFF] { + + if bytes.len() > 2 && ((bytes[0..=1] == [0xFE, 0xFF]) || (bytes[0..=1] == [0xFF, 0xFE])) { + if bytes[0..=1] == [0xFE, 0xFF] { return Some(CharacterSet::UTF16BE); } else { return Some(CharacterSet::UTF16LE); @@ -121,7 +119,7 @@ impl StringUtils { let mut sjis_max_double_bytes_word_length = 0; let mut iso_high_other = 0; - let utf8bom = bytes.len() > 3 && bytes[0..=2] == [ 0xEF , 0xBB , 0xBF]; + let utf8bom = bytes.len() > 3 && bytes[0..=2] == [0xEF, 0xBB, 0xBF]; // for i in 0..length { for value in bytes.iter().take(length).copied() { diff --git a/src/oned/telepen_reader.rs b/src/oned/telepen_reader.rs index 999769fb..8339ef16 100644 --- a/src/oned/telepen_reader.rs +++ b/src/oned/telepen_reader.rs @@ -71,12 +71,8 @@ impl OneDReader for TelepenReader { // largest gaps. while j <= end { let currentCounter = theCounters[j]; - if currentCounter < minBar { - minBar = currentCounter; - } - if currentCounter > maxBar { - maxBar = currentCounter; - } + minBar = u32::min(currentCounter, minBar); + maxBar = u32::max(currentCounter, maxBar); j += 1; }