fixed clippy errors

This commit is contained in:
Henry Schimke
2022-10-16 13:09:24 -05:00
parent c63dd67e4d
commit accf587bea
5 changed files with 19 additions and 19 deletions

View File

@@ -76,9 +76,9 @@ impl State {
let result = self.shiftAndAppend(HighLevelEncoder::MODE_PUNCT as u32, 0); // 0: FLG(n) let result = self.shiftAndAppend(HighLevelEncoder::MODE_PUNCT as u32, 0); // 0: FLG(n)
let mut token = result.token; let mut token = result.token;
let mut bits_added = 3; let mut bits_added = 3;
if eci < 0 { /*if eci < 0 {
token.add(0, 3); // 0: FNC1 token.add(0, 3); // 0: FNC1
} else if eci > 999999 { } else */if eci > 999999 {
return Err(Exceptions::IllegalArgumentException( return Err(Exceptions::IllegalArgumentException(
"ECI code must be between 0 and 999999".to_owned(), "ECI code must be between 0 and 999999".to_owned(),
)); ));

View File

@@ -239,7 +239,7 @@ pub fn isStringOfDigits(value: &str, length: usize) -> bool {
} }
pub fn isSubstringOfDigits(value: &str, offset: usize, length: usize) -> bool { pub fn isSubstringOfDigits(value: &str, offset: usize, length: usize) -> bool {
if value.is_empty() || length <= 0 { if value.is_empty() || length == 0 {
return false; return false;
} }
let max = offset as usize + length; let max = offset as usize + length;

View File

@@ -173,8 +173,8 @@ pub fn matchVCardPrefixedField(
parseFieldDivider: bool, parseFieldDivider: bool,
) -> Option<Vec<Vec<String>>> { ) -> Option<Vec<Vec<String>>> {
let mut matches: Vec<Vec<String>> = Vec::new(); let mut matches: Vec<Vec<String>> = Vec::new();
let mut i = 0; let mut i = 0_isize;
let max = rawText.len(); let max = rawText.len() as isize;
// let equals_regex = Regex::new(EQUALS).unwrap(); // let equals_regex = Regex::new(EQUALS).unwrap();
// let unescaped_semis = fancy_regex::Regex::new(UNESCAPED_SEMICOLONS).unwrap(); // let unescaped_semis = fancy_regex::Regex::new(UNESCAPED_SEMICOLONS).unwrap();
@@ -195,14 +195,14 @@ pub fn matchVCardPrefixedField(
if i > 0 { if i > 0 {
i -= 1; // Find from i-1 not i since looking at the preceding character i -= 1; // Find from i-1 not i since looking at the preceding character
} }
let cap_text = &rawText[i..]; let cap_text = &rawText[i as usize..];
let cap_maybe = matcher_primary.captures(cap_text); let cap_maybe = matcher_primary.captures(cap_text);
//let matcher_maybe = matcher_primary.find_at(&lower_case_raw_text, i); //let matcher_maybe = matcher_primary.find_at(&lower_case_raw_text, i);
if cap_maybe.is_none() { if cap_maybe.is_none() {
break; break;
} }
let matcher = cap_maybe?; let matcher = cap_maybe?;
i += matcher.get(0)?.end(); // group 0 = whole pattern; end(0) is past final colon i += matcher.get(0)?.end() as isize; // group 0 = whole pattern; end(0) is past final colon
let metadataString = matcher.get(1); // group 1 = metadata substring let metadataString = matcher.get(1); // group 1 = metadata substring
let mut metadata: Vec<String> = Vec::new(); let mut metadata: Vec<String> = Vec::new();
@@ -236,18 +236,18 @@ pub fn matchVCardPrefixedField(
} }
let matchStart = i; // Found the start of a match here let matchStart = i; // Found the start of a match here
while let Some(pos) = rawText[i..].find('\n') { while let Some(pos) = rawText[i as usize..].find('\n') {
// Really, end in \r\n // Really, end in \r\n
i += pos; // + i; i += pos as isize; // + i;
// while (i = rawText.indexOf('\n', i)) >= 0 { // Really, end in \r\n // while (i = rawText.indexOf('\n', i)) >= 0 { // Really, end in \r\n
if i < rawText.len() - 1 && // But if followed by tab or space, if i < rawText.len() as isize- 1 && // But if followed by tab or space,
(rawText.chars().nth(i + 1)? == ' ' || // this is only a continuation (rawText.chars().nth(i as usize+ 1)? == ' ' || // this is only a continuation
rawText.chars().nth(i + 1)? == '\t') rawText.chars().nth(i as usize+ 1)? == '\t')
{ {
i += 2; // Skip \n and continutation whitespace i += 2; // Skip \n and continutation whitespace
} else if quotedPrintable && // If preceded by = in quoted printable } else if quotedPrintable && // If preceded by = in quoted printable
((i >= 1 && rawText.chars().nth(i - 1)? == '=') || // this is a continuation ((i >= 1 && rawText.chars().nth(i as usize- 1)? == '=') || // this is a continuation
(i >= 2 && rawText.chars().nth(i - 2)? == '=')) (i >= 2 && rawText.chars().nth(i as usize - 2)? == '='))
{ {
i += 1; // Skip \n i += 1; // Skip \n
} else { } else {
@@ -263,10 +263,10 @@ pub fn matchVCardPrefixedField(
// if matches == null { // if matches == null {
// matches = new ArrayList<>(1); // lazy init // matches = new ArrayList<>(1); // lazy init
// } // }
if i >= 1 && rawText.chars().nth(i - 1)? == '\r' { if i >= 1 && rawText.chars().nth(i as usize- 1)? == '\r' {
i -= 1; // Back up over \r, which really should be there i -= 1; // Back up over \r, which really should be there
} }
let mut element = rawText[matchStart..i].to_owned(); let mut element = rawText[matchStart as usize..i as usize].to_owned();
if trim { if trim {
element = element.trim().to_owned(); element = element.trim().to_owned();
} }

View File

@@ -2342,7 +2342,7 @@ impl GridSampler for DefaultGridSampler {
dimensionY: u32, dimensionY: u32,
transform: &PerspectiveTransform, transform: &PerspectiveTransform,
) -> Result<BitMatrix, Exceptions> { ) -> Result<BitMatrix, Exceptions> {
if dimensionX <= 0 || dimensionY <= 0 { if dimensionX == 0 || dimensionY == 0 {
return Err(Exceptions::NotFoundException( return Err(Exceptions::NotFoundException(
"getNotFoundInstance".to_owned(), "getNotFoundInstance".to_owned(),
)); ));
@@ -3227,7 +3227,7 @@ impl ECIInput for MinimalECIInput {
if 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)
} }
/** /**

View File

@@ -967,7 +967,7 @@ impl ReedSolomonEncoder {
)); ));
} }
let data_bytes = to_encode.len() - ec_bytes; let data_bytes = to_encode.len() - ec_bytes;
if data_bytes <= 0 { if data_bytes == 0 {
return Err(Exceptions::IllegalArgumentException( return Err(Exceptions::IllegalArgumentException(
"No data bytes provided".to_owned(), "No data bytes provided".to_owned(),
)); ));