cargo clippy --fix

This commit is contained in:
Henry Schimke
2023-05-04 13:45:57 -05:00
parent e8501c1b6e
commit 634722a806
16 changed files with 50 additions and 50 deletions

View File

@@ -429,8 +429,8 @@ impl Into<Vec<bool>> for BitArray {
fn into(self) -> Vec<bool> {
let mut array = vec![false; self.size];
for pixel in 0..self.size {
array[pixel] = self.get(pixel);
for (pixel, element) in array.iter_mut().enumerate().take(self.size) {
*element = self.get(pixel);
}
array

View File

@@ -139,7 +139,7 @@ impl BitSource {
num_bits -= toRead;
bit_offset += toRead;
if bit_offset == 8 {
bit_offset = 0;
//bit_offset = 0;
byte_offset += 1;
}
}

View File

@@ -100,12 +100,12 @@ impl FormatInformation {
// Some QR codes apparently do not apply the XOR mask. Try without and with additional masking.
for mask in [0, mask] {
// for (auto mask : {0, mask})
for bitsIndex in 0..bits.len() {
for (bitsIndex, bit_set) in bits.iter().enumerate() {
// for (int bitsIndex = 0; bitsIndex < Size(bits); ++bitsIndex)
for [pattern, index] in lookup {
// for (const auto& [pattern, index] : lookup) {
// Find the int in lookup with fewest bits differing
let hammingDist = ((bits[bitsIndex] ^ mask) ^ pattern).count_ones();
let hammingDist = ((bit_set ^ mask) ^ pattern).count_ones();
if hammingDist < fi.hammingDistance {
// if (int hammingDist = BitHacks::CountBitsSet((bits[bitsIndex] ^ mask) ^ pattern); hammingDist < fi.hammingDistance) {
fi.index = index as u8;

View File

@@ -63,12 +63,11 @@ impl Version {
pub fn DecodeVersionInformation(versionBitsA: i32, versionBitsB: i32) -> Result<VersionRef> {
let mut bestDifference = u32::MAX;
let mut bestVersion = 0;
let mut i = 0;
for targetVersion in VERSION_DECODE_INFO {
for (i, targetVersion) in VERSION_DECODE_INFO.into_iter().enumerate() {
// for (int targetVersion : VERSION_DECODE_INFO) {
// Do the version info bits match exactly? done.
if targetVersion == versionBitsA as u32 || targetVersion == versionBitsB as u32 {
return Self::getVersionForNumber(i + 7);
return Self::getVersionForNumber(i as u32 + 7);
}
// Otherwise see if this is the closest to a real version info bit string
// we have seen so far
@@ -80,12 +79,11 @@ impl Version {
bestDifference = bitsDifference;
}
}
i += 1;
}
// We can tolerate up to 3 bits of error since no two version info codewords will
// differ in less than 8 bits.
if bestDifference <= 3 {
return Self::getVersionForNumber(bestVersion);
return Self::getVersionForNumber(bestVersion as u32);
}
// If we didn't find a close enough match, fail
Err(Exceptions::ILLEGAL_STATE)

View File

@@ -49,10 +49,10 @@ where
Self::default()
}
pub fn with_eci_string_builder(src: ECIStringBuilder) -> Self {
let mut new_self = Self::default();
new_self.content = src;
new_self
DecoderResult::<T> {
content: src,
..Default::default()
}
}
pub fn isValid(&self) -> bool {

View File

@@ -80,7 +80,7 @@ pub struct PatternViewIterator<'a> {
current_position: usize,
}
impl<'a> Iterator for PatternViewIterator<'_> {
impl Iterator for PatternViewIterator<'_> {
type Item = PatternType;
fn next(&mut self) -> Option<Self::Item> {
@@ -243,7 +243,7 @@ impl<'a> PatternView<'a> {
pub fn shift(&mut self, n: usize) -> bool {
self.current += n;
!self.data.0.is_empty() && self.start + self.count <= (self.start + self.count)
!self.data.0.is_empty() //&& self.start + self.count <= (self.start + self.count)
}
pub fn skipPair(&mut self) -> bool {
@@ -278,7 +278,7 @@ impl<'a> PatternView<'a> {
}
}
impl<'a> std::ops::Index<isize> for PatternView<'_> {
impl std::ops::Index<isize> for PatternView<'_> {
type Output = PatternType;
fn index(&self, index: isize) -> &Self::Output {
@@ -301,7 +301,7 @@ impl<'a> std::ops::Index<isize> for PatternView<'_> {
}
}
impl<'a> std::ops::Index<usize> for PatternView<'_> {
impl std::ops::Index<usize> for PatternView<'_> {
type Output = PatternType;
fn index(&self, index: usize) -> &Self::Output {
@@ -316,7 +316,7 @@ impl<'a> std::ops::Index<usize> for PatternView<'_> {
}
}
impl<'a> std::ops::Index<i32> for PatternView<'_> {
impl std::ops::Index<i32> for PatternView<'_> {
type Output = PatternType;
fn index(&self, index: i32) -> &Self::Output {

View File

@@ -37,7 +37,7 @@ impl GridSampler for DefaultGridSampler {
dimensionY: u32,
controls: &[SamplerControl],
) -> Result<(BitMatrix, [Point; 4])> {
if dimensionX <= 0 || dimensionY <= 0 {
if dimensionX == 0 || dimensionY == 0 {
return Err(Exceptions::NOT_FOUND);
}

View File

@@ -417,9 +417,10 @@ fn test_encode_decode_random(field: GenericGFRef, dataSize: usize, ecSize: usize
for _i in 0..iterations {
//for (int i = 0; i < iterations; i++) {
// generate random data
for k in 0..dataSize {
for data in dataWords.iter_mut().take(dataSize) {
// for k in 0..dataSize {
//for (int k = 0; k < dataSize; k++) {
dataWords[k] = random.gen_range(0..field.getSize().try_into().unwrap());
*data = random.gen_range(0..field.getSize().try_into().unwrap());
}
// generate ECC words
message[0..dataWords.len()].clone_from_slice(&dataWords[..]);