mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
fixed clippy errors
This commit is contained in:
@@ -76,9 +76,9 @@ impl State {
|
||||
let result = self.shiftAndAppend(HighLevelEncoder::MODE_PUNCT as u32, 0); // 0: FLG(n)
|
||||
let mut token = result.token;
|
||||
let mut bits_added = 3;
|
||||
if eci < 0 {
|
||||
/*if eci < 0 {
|
||||
token.add(0, 3); // 0: FNC1
|
||||
} else if eci > 999999 {
|
||||
} else */if eci > 999999 {
|
||||
return Err(Exceptions::IllegalArgumentException(
|
||||
"ECI code must be between 0 and 999999".to_owned(),
|
||||
));
|
||||
|
||||
@@ -239,7 +239,7 @@ pub fn isStringOfDigits(value: &str, 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;
|
||||
}
|
||||
let max = offset as usize + length;
|
||||
|
||||
@@ -173,8 +173,8 @@ pub fn matchVCardPrefixedField(
|
||||
parseFieldDivider: bool,
|
||||
) -> Option<Vec<Vec<String>>> {
|
||||
let mut matches: Vec<Vec<String>> = Vec::new();
|
||||
let mut i = 0;
|
||||
let max = rawText.len();
|
||||
let mut i = 0_isize;
|
||||
let max = rawText.len() as isize;
|
||||
|
||||
// let equals_regex = Regex::new(EQUALS).unwrap();
|
||||
// let unescaped_semis = fancy_regex::Regex::new(UNESCAPED_SEMICOLONS).unwrap();
|
||||
@@ -195,14 +195,14 @@ pub fn matchVCardPrefixedField(
|
||||
if i > 0 {
|
||||
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 matcher_maybe = matcher_primary.find_at(&lower_case_raw_text, i);
|
||||
if cap_maybe.is_none() {
|
||||
break;
|
||||
}
|
||||
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 mut metadata: Vec<String> = Vec::new();
|
||||
@@ -236,18 +236,18 @@ pub fn matchVCardPrefixedField(
|
||||
}
|
||||
|
||||
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
|
||||
i += pos; // + i;
|
||||
i += pos as isize; // + i;
|
||||
// while (i = rawText.indexOf('\n', i)) >= 0 { // Really, end in \r\n
|
||||
if i < rawText.len() - 1 && // But if followed by tab or space,
|
||||
(rawText.chars().nth(i + 1)? == ' ' || // this is only a continuation
|
||||
rawText.chars().nth(i + 1)? == '\t')
|
||||
if i < rawText.len() as isize- 1 && // But if followed by tab or space,
|
||||
(rawText.chars().nth(i as usize+ 1)? == ' ' || // this is only a continuation
|
||||
rawText.chars().nth(i as usize+ 1)? == '\t')
|
||||
{
|
||||
i += 2; // Skip \n and continutation whitespace
|
||||
} else if quotedPrintable && // If preceded by = in quoted printable
|
||||
((i >= 1 && rawText.chars().nth(i - 1)? == '=') || // this is a continuation
|
||||
(i >= 2 && rawText.chars().nth(i - 2)? == '='))
|
||||
((i >= 1 && rawText.chars().nth(i as usize- 1)? == '=') || // this is a continuation
|
||||
(i >= 2 && rawText.chars().nth(i as usize - 2)? == '='))
|
||||
{
|
||||
i += 1; // Skip \n
|
||||
} else {
|
||||
@@ -263,10 +263,10 @@ pub fn matchVCardPrefixedField(
|
||||
// if matches == null {
|
||||
// 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
|
||||
}
|
||||
let mut element = rawText[matchStart..i].to_owned();
|
||||
let mut element = rawText[matchStart as usize..i as usize].to_owned();
|
||||
if trim {
|
||||
element = element.trim().to_owned();
|
||||
}
|
||||
|
||||
@@ -2342,7 +2342,7 @@ impl GridSampler for DefaultGridSampler {
|
||||
dimensionY: u32,
|
||||
transform: &PerspectiveTransform,
|
||||
) -> Result<BitMatrix, Exceptions> {
|
||||
if dimensionX <= 0 || dimensionY <= 0 {
|
||||
if dimensionX == 0 || dimensionY == 0 {
|
||||
return Err(Exceptions::NotFoundException(
|
||||
"getNotFoundInstance".to_owned(),
|
||||
));
|
||||
@@ -3227,7 +3227,7 @@ impl ECIInput for MinimalECIInput {
|
||||
if index >= self.length() as u32 {
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -967,7 +967,7 @@ impl ReedSolomonEncoder {
|
||||
));
|
||||
}
|
||||
let data_bytes = to_encode.len() - ec_bytes;
|
||||
if data_bytes <= 0 {
|
||||
if data_bytes == 0 {
|
||||
return Err(Exceptions::IllegalArgumentException(
|
||||
"No data bytes provided".to_owned(),
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user