cargo fix

This commit is contained in:
Henry
2023-04-28 19:15:25 -05:00
parent 9a8df1931b
commit 2afc6be3dc
22 changed files with 157 additions and 158 deletions

View File

@@ -18,7 +18,7 @@
// import java.util.Arrays;
use std::ops::Index;
use std::{cmp, fmt};
use crate::common::Result;

View File

@@ -63,9 +63,9 @@ impl BitMatrix {
let mut right = 0;
let mut bottom = 0;
if (!self.getTopLeftOnBitWithPosition(&mut left, &mut top)
if !self.getTopLeftOnBitWithPosition(&mut left, &mut top)
|| !self.getBottomRightOnBitWithPosition(&mut right, &mut bottom)
|| bottom - top + 1 < minSize)
|| bottom - top + 1 < minSize
{
return (false, left, top, width, height);
}
@@ -74,14 +74,14 @@ impl BitMatrix {
// for (int y = top; y <= bottom; y++ ) {
for x in 0..left {
// for (int x = 0; x < left; ++x){
if (self.get(x, y)) {
if self.get(x, y) {
left = x;
break;
}
}
for x in (right..(self.width() - 1)).rev() {
// for (int x = _width-1; x > right; x--){
if (self.get(x, y)) {
if self.get(x, y) {
right = x;
break;
}

View File

@@ -1,9 +1,9 @@
use crate::common::Result;
use crate::qrcode::decoder::ErrorCorrectionLevel;
impl ErrorCorrectionLevel {
pub fn ECLevelFromBitsSigned(bits: i8, isMicro: bool) -> Self {
if (isMicro) {
if isMicro {
let LEVEL_FOR_BITS: [ErrorCorrectionLevel; 8] = [
ErrorCorrectionLevel::L,
ErrorCorrectionLevel::L,

View File

@@ -1,4 +1,4 @@
use crate::common::Result;
use crate::qrcode::decoder::{
ErrorCorrectionLevel, FormatInformation, FORMAT_INFO_DECODE_LOOKUP, FORMAT_INFO_MASK_QR,
@@ -84,7 +84,7 @@ impl FormatInformation {
// Bits 2/3/4 contain both error correction level and version, 0/1 contain mask.
fi.error_correction_level =
ErrorCorrectionLevel::ECLevelFromBits((fi.index >> 2) & 0x07, true);
fi.data_mask = (fi.index & 0x03);
fi.data_mask = fi.index & 0x03;
fi.microVersion = BITS_TO_VERSION[((fi.index >> 2) & 0x07) as usize] as u32;
fi.isMirrored = fi.bitsIndex == 1;

View File

@@ -18,7 +18,7 @@ use crate::Exceptions;
impl Version {
pub fn FromDimension(dimension: u32) -> Result<VersionRef> {
let isMicro = dimension < 21;
if (dimension % Self::DimensionStep(isMicro) != 1) {
if dimension % Self::DimensionStep(isMicro) != 1 {
//throw std::invalid_argument("Unexpected dimension");
return Err(Exceptions::ILLEGAL_ARGUMENT);
}
@@ -29,7 +29,7 @@ impl Version {
}
pub fn FromNumber(versionNumber: u32, is_micro: bool) -> Result<VersionRef> {
if (versionNumber < 1 || versionNumber > (if is_micro { 4 } else { 40 })) {
if versionNumber < 1 || versionNumber > (if is_micro { 4 } else { 40 }) {
//throw std::invalid_argument("Version should be in range [1-40].");
return Err(Exceptions::ILLEGAL_ARGUMENT);
}

View File

@@ -188,9 +188,9 @@ pub trait BitMatrixCursorTrait {
range: Option<i32>,
) -> Option<[T; LEN]> {
let range = range.unwrap_or(0);
if (maxWhitePrefix != 0
if maxWhitePrefix != 0
&& self.isWhite()
&& !self.stepToEdge(Some(1), Some(maxWhitePrefix), None) > 0)
&& !self.stepToEdge(Some(1), Some(maxWhitePrefix), None) > 0
{
return None;
}

View File

@@ -5,10 +5,10 @@ use crate::{
},
BitMatrix, Quadrilateral,
},
point, Exceptions, Point,
point, Point,
};
use crate::common::Result;
use super::{
BitMatrixCursorTrait, EdgeTracer, FastEdgeToEdgeCounter, Pattern, RegressionLine,
@@ -265,7 +265,7 @@ pub fn CenterOfRings(
// for (int i = 1; i < numOfRings; ++i) {
let c = CenterOfRing(image, center.floor(), range, i as i32, true)?;
if (c == Point::default()) {
if c == Point::default() {
if n == 1 {
return None;
} else {
@@ -342,7 +342,7 @@ pub fn CollectRingPoints(
}
pub fn FitQadrilateralToPoints(center: Point, points: &mut [Point]) -> Option<Quadrilateral> {
let dist2Center = |a, b| Point::distance(a, center) < Point::distance(b, center);
let _dist2Center = |a, b| Point::distance(a, center) < Point::distance(b, center);
// rotate points such that the first one is the furthest away from the center (hence, a corner)
let max_by_pred = |a: &&Point, b: &&Point| {
@@ -372,7 +372,7 @@ pub fn FitQadrilateralToPoints(center: Point, points: &mut [Point]) -> Option<Qu
// corners[2] = std::max_element(&points[Size(points) * 3 / 8], &points[Size(points) * 5 / 8], dist2Center);
// find the two in between corners by looking for the points farthest from the long diagonal
let l = RegressionLine::with_two_points(corners[0], corners[2]);
let dist2Diagonal = /*[l = RegressionLine(*corners[0], *corners[2])]*/| a, b| { l.distance_single(a) < l.distance_single(b) };
let _dist2Diagonal = /*[l = RegressionLine(*corners[0], *corners[2])]*/| a, b| { l.distance_single(a) < l.distance_single(b) };
let diagonal_max_by_pred = |p1: &Point, p2: &Point| {
let d1 = l.distance_single(*p1);
@@ -448,8 +448,8 @@ pub fn FitQadrilateralToPoints(center: Point, points: &mut [Point]) -> Option<Qu
for p in &points[beg[i]..end[i]] {
// for (const PointF* p = beg[i]; p != end[i]; ++p) {
let len = (end[i] - beg[i]) as f64; //std::distance(beg[i], end[i]);
if (len > 3.0
&& (lines[i].distance_single(*p) as f64) > f64::max(1.0, f64::min(8.0, len / 8.0)))
if len > 3.0
&& (lines[i].distance_single(*p) as f64) > f64::max(1.0, f64::min(8.0, len / 8.0))
{
// #ifdef PRINT_DEBUG
// printf("%d: %.2f > %.2f @ %.fx%.f\n", i, lines[i].distance(*p), std::distance(beg[i], end[i]) / 1., p->x, p->y);
@@ -649,7 +649,7 @@ pub fn FinetuneConcentricPatternCenter(
return Some(res2);
}
// or the center can be approximated by a square
if (FitSquareToPoints(image, res1, range, 1, false).is_some()) {
if FitSquareToPoints(image, res1, range, 1, false).is_some() {
return Some(res1);
}
// TODO: this is currently only keeping #258 alive, evaluate if still worth it

View File

@@ -1,6 +1,6 @@
use std::{any::Any, rc::Rc};
use std::{rc::Rc};
use crate::{common::ECIStringBuilder, Exceptions, RXingResult};
use crate::{common::ECIStringBuilder, Exceptions};
use super::StructuredAppendInfo;

View File

@@ -23,7 +23,7 @@ impl<T: Default + Clone + Copy> Matrix<T> {
}
pub fn new(width: usize, height: usize) -> Result<Matrix<T>> {
if (width != 0 && (width * height) / width as usize != height as usize) {
if width != 0 && (width * height) / width as usize != height as usize {
return Err(Exceptions::illegal_argument_with(
"invalid size: width * height is too big",
));

View File

@@ -500,13 +500,13 @@ pub fn IsPattern<const E2E: bool, const LEN: usize, const SUM: usize, const SPAR
f64::min(modSize[0], modSize[1]),
f64::max(modSize[0], modSize[1]),
];
if (M > 4.0 * m) {
if M > 4.0 * m {
// make sure module sizes of bars and spaces are not too far away from each other
return 0.0;
}
if (min_quiet_zone != 0.0
&& (space_in_pixel.unwrap_or_default()) < min_quiet_zone * modSize.space as f32)
if min_quiet_zone != 0.0
&& (space_in_pixel.unwrap_or_default()) < min_quiet_zone * modSize.space as f32
{
return 0.0;
}

View File

@@ -23,10 +23,10 @@
use std::{
collections::{HashMap, HashSet},
fmt::{self, Display},
fmt::{self},
};
use crate::{pdf417::decoder::ec, BarcodeFormat};
use super::{CharacterSet, Eci, StringUtils};

View File

@@ -1,6 +1,6 @@
use crate::{point, Point};
use super::PerspectiveTransform;
#[derive(Clone, Copy, Debug)]
pub struct Quadrilateral(pub [Point; 4]);