mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
working through clippy errors
This commit is contained in:
@@ -26,7 +26,8 @@ use imageproc::geometric_transformations::rotate_about_center;
|
|||||||
|
|
||||||
use crate::LuminanceSource;
|
use crate::LuminanceSource;
|
||||||
|
|
||||||
const MINUS_45_IN_RADIANS: f32 = -0.7853981633974483; // Math.toRadians(-45.0)
|
// const MINUS_45_IN_RADIANS: f32 = -0.7853981633974483; // Math.toRadians(-45.0)
|
||||||
|
const MINUS_45_IN_RADIANS : f32 = std::f32::consts::FRAC_PI_4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This LuminanceSource implementation is meant for J2SE clients and our blackbox unit tests.
|
* This LuminanceSource implementation is meant for J2SE clients and our blackbox unit tests.
|
||||||
|
|||||||
@@ -3158,10 +3158,10 @@ impl ECIInput for MinimalECIInput {
|
|||||||
* if the value at the {@code index} argument is an ECI (@see #isECI)
|
* if the value at the {@code index} argument is an ECI (@see #isECI)
|
||||||
*/
|
*/
|
||||||
fn charAt(&self, index: usize) -> Result<char, Exceptions> {
|
fn charAt(&self, index: usize) -> Result<char, Exceptions> {
|
||||||
if (index < 0 || index >= self.length()) {
|
if index >= self.length() {
|
||||||
return Err(Exceptions::IndexOutOfBoundsException(index.to_string()));
|
return Err(Exceptions::IndexOutOfBoundsException(index.to_string()));
|
||||||
}
|
}
|
||||||
if (self.isECI(index as u32)?) {
|
if self.isECI(index as u32)? {
|
||||||
return Err(Exceptions::IllegalArgumentException(format!(
|
return Err(Exceptions::IllegalArgumentException(format!(
|
||||||
"value at {} is not a character but an ECI",
|
"value at {} is not a character but an ECI",
|
||||||
index
|
index
|
||||||
@@ -3195,7 +3195,7 @@ impl ECIInput for MinimalECIInput {
|
|||||||
* if a value in the range {@code start}-{@code end} is an ECI (@see #isECI)
|
* if a value in the range {@code start}-{@code end} is an ECI (@see #isECI)
|
||||||
*/
|
*/
|
||||||
fn subSequence(&self, start: usize, end: usize) -> Result<Vec<char>, Exceptions> {
|
fn subSequence(&self, start: usize, end: usize) -> Result<Vec<char>, Exceptions> {
|
||||||
if start < 0 || start > end || end > self.length() {
|
if start > end || end > self.length() {
|
||||||
return Err(Exceptions::IndexOutOfBoundsException(start.to_string()));
|
return Err(Exceptions::IndexOutOfBoundsException(start.to_string()));
|
||||||
}
|
}
|
||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
@@ -3224,7 +3224,7 @@ impl ECIInput for MinimalECIInput {
|
|||||||
* {@code length()}
|
* {@code length()}
|
||||||
*/
|
*/
|
||||||
fn isECI(&self, index: u32) -> Result<bool, Exceptions> {
|
fn isECI(&self, index: u32) -> Result<bool, Exceptions> {
|
||||||
if index < 0 || index >= self.length() as u32 {
|
if index >= self.length() as u32 {
|
||||||
return Err(Exceptions::IndexOutOfBoundsException(index.to_string()));
|
return Err(Exceptions::IndexOutOfBoundsException(index.to_string()));
|
||||||
}
|
}
|
||||||
Ok(self.bytes[index as usize] > 255 && self.bytes[index as usize] <= u16::MAX)
|
Ok(self.bytes[index as usize] > 255 && self.bytes[index as usize] <= u16::MAX)
|
||||||
@@ -3249,7 +3249,7 @@ impl ECIInput for MinimalECIInput {
|
|||||||
* if the value at the {@code index} argument is not an ECI (@see #isECI)
|
* if the value at the {@code index} argument is not an ECI (@see #isECI)
|
||||||
*/
|
*/
|
||||||
fn getECIValue(&self, index: usize) -> Result<u32, Exceptions> {
|
fn getECIValue(&self, index: usize) -> Result<u32, Exceptions> {
|
||||||
if index < 0 || index >= self.length() {
|
if index >= self.length() {
|
||||||
return Err(Exceptions::IndexOutOfBoundsException(index.to_string()));
|
return Err(Exceptions::IndexOutOfBoundsException(index.to_string()));
|
||||||
}
|
}
|
||||||
if !self.isECI(index as u32)? {
|
if !self.isECI(index as u32)? {
|
||||||
@@ -3336,7 +3336,7 @@ impl MinimalECIInput {
|
|||||||
* {@code length()}
|
* {@code length()}
|
||||||
*/
|
*/
|
||||||
pub fn isFNC1(&self, index: usize) -> Result<bool, Exceptions> {
|
pub fn isFNC1(&self, index: usize) -> Result<bool, Exceptions> {
|
||||||
if index < 0 || index >= self.length() {
|
if index >= self.length() {
|
||||||
return Err(Exceptions::IndexOutOfBoundsException(index.to_string()));
|
return Err(Exceptions::IndexOutOfBoundsException(index.to_string()));
|
||||||
}
|
}
|
||||||
Ok(self.bytes[index] == 1000)
|
Ok(self.bytes[index] == 1000)
|
||||||
|
|||||||
@@ -1351,9 +1351,6 @@ pub struct Dimension {
|
|||||||
|
|
||||||
impl Dimension {
|
impl Dimension {
|
||||||
pub fn new(width: usize, height: usize) -> Result<Self, Exceptions> {
|
pub fn new(width: usize, height: usize) -> Result<Self, Exceptions> {
|
||||||
if width < 0 || height < 0 {
|
|
||||||
return Err(Exceptions::IllegalArgumentException("".to_owned()));
|
|
||||||
}
|
|
||||||
Ok(Self { width, height })
|
Ok(Self { width, height })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2028,7 +2025,7 @@ impl PlanarYUVLuminanceSource {
|
|||||||
|
|
||||||
impl LuminanceSource for PlanarYUVLuminanceSource {
|
impl LuminanceSource for PlanarYUVLuminanceSource {
|
||||||
fn getRow(&self, y: usize, row: &Vec<u8>) -> Vec<u8> {
|
fn getRow(&self, y: usize, row: &Vec<u8>) -> Vec<u8> {
|
||||||
if y < 0 || y >= self.getHeight() {
|
if y >= self.getHeight() {
|
||||||
//throw new IllegalArgumentException("Requested row is outside the image: " + y);
|
//throw new IllegalArgumentException("Requested row is outside the image: " + y);
|
||||||
panic!("Requested row is outside the image: {}", y);
|
panic!("Requested row is outside the image: {}", y);
|
||||||
}
|
}
|
||||||
@@ -2178,7 +2175,7 @@ pub struct RGBLuminanceSource {
|
|||||||
|
|
||||||
impl LuminanceSource for RGBLuminanceSource {
|
impl LuminanceSource for RGBLuminanceSource {
|
||||||
fn getRow(&self, y: usize, row: &Vec<u8>) -> Vec<u8> {
|
fn getRow(&self, y: usize, row: &Vec<u8>) -> Vec<u8> {
|
||||||
if y < 0 || y >= self.getHeight() {
|
if y >= self.getHeight() {
|
||||||
panic!("Requested row is outside the image: {}", y);
|
panic!("Requested row is outside the image: {}", y);
|
||||||
}
|
}
|
||||||
let width = self.getWidth();
|
let width = self.getWidth();
|
||||||
|
|||||||
@@ -90,9 +90,10 @@ impl DataBlock {
|
|||||||
// (where n may be 0) have 1 more byte. Figure out where these start.
|
// (where n may be 0) have 1 more byte. Figure out where these start.
|
||||||
let shorterBlocksTotalCodewords = result[0].codewords.len();
|
let shorterBlocksTotalCodewords = result[0].codewords.len();
|
||||||
let mut longerBlocksStartAt = result.len() - 1;
|
let mut longerBlocksStartAt = result.len() - 1;
|
||||||
while (longerBlocksStartAt >= 0) {
|
loop {
|
||||||
|
//while longerBlocksStartAt >= 0 {
|
||||||
let numCodewords = result[longerBlocksStartAt].codewords.len();
|
let numCodewords = result[longerBlocksStartAt].codewords.len();
|
||||||
if (numCodewords == shorterBlocksTotalCodewords) {
|
if numCodewords == shorterBlocksTotalCodewords {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
longerBlocksStartAt-=1;
|
longerBlocksStartAt-=1;
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ impl QRCodeReader {
|
|||||||
}
|
}
|
||||||
let matrixWidth = ((right as f32 - left as f32 + 1.0) / moduleSize).round() as u32;
|
let matrixWidth = ((right as f32 - left as f32 + 1.0) / moduleSize).round() as u32;
|
||||||
let matrixHeight = ((bottom as f32 - top as f32 + 1.0) / moduleSize).round() as u32;
|
let matrixHeight = ((bottom as f32 - top as f32 + 1.0) / moduleSize).round() as u32;
|
||||||
if matrixWidth <= 0 || matrixHeight <= 0 {
|
if matrixWidth == 0 || matrixHeight == 0 {
|
||||||
return Err(Exceptions::NotFoundException("".to_owned()));
|
return Err(Exceptions::NotFoundException("".to_owned()));
|
||||||
}
|
}
|
||||||
if matrixHeight != matrixWidth {
|
if matrixHeight != matrixWidth {
|
||||||
|
|||||||
Reference in New Issue
Block a user