clippy fix

This commit is contained in:
Henry Schimke
2023-05-04 13:53:57 -05:00
parent 634722a806
commit 326da6808a
3 changed files with 26 additions and 27 deletions

View File

@@ -410,27 +410,20 @@ impl Default for BitArray {
}
}
impl Into<Vec<u8>> for BitArray {
fn into(self) -> Vec<u8> {
let mut array = vec![0; self.getSizeInBytes()];
self.toBytes(0, &mut array, 0, self.getSizeInBytes());
impl From<BitArray> for Vec<u8> {
fn from(value: BitArray) -> Self {
let mut array = vec![0; value.getSizeInBytes()];
value.toBytes(0, &mut array, 0, value.getSizeInBytes());
array
// let mut arr = vec![0; self.get_size()];
// for x in 0..self.get_size() {
// if self.get(x) {
// arr[x] = 1;
// }
// }
// arr
}
}
impl Into<Vec<bool>> for BitArray {
fn into(self) -> Vec<bool> {
let mut array = vec![false; self.size];
impl From<BitArray> for Vec<bool> {
fn from(value: BitArray) -> Self {
let mut array = vec![false; value.size];
for (pixel, element) in array.iter_mut().enumerate().take(self.size) {
*element = self.get(pixel);
for (pixel, element) in array.iter_mut().enumerate().take(value.size) {
*element = value.get(pixel);
}
array

View File

@@ -40,6 +40,10 @@ impl PatternRow {
self.0.len()
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
pub fn into_pattern_view(&self) -> PatternView {
PatternView::new(self)
}
@@ -324,21 +328,21 @@ impl std::ops::Index<i32> for PatternView<'_> {
}
}
impl<'a> Into<Vec<PatternType>> for &PatternView<'a> {
fn into(self) -> Vec<PatternType> {
let mut v = vec![PatternType::default(); self.count];
for i in 0..self.count {
v[i] = self[i];
impl<'a> From<&PatternView<'a>> for Vec<PatternType> {
fn from(value: &PatternView<'a>) -> Self {
let mut v = vec![PatternType::default(); value.count];
for i in 0..value.count {
v[i] = value[i];
}
v
}
}
impl<'a, const LEN: usize> Into<[PatternType; LEN]> for &PatternView<'a> {
fn into(self) -> [PatternType; LEN] {
impl<'a, const LEN: usize> From<&PatternView<'a>> for [PatternType; LEN] {
fn from(value: &PatternView<'a>) -> Self {
let mut result = [PatternType::default(); LEN];
for i in 0..self.count {
result[i] = self[i];
for i in 0..value.count {
result[i] = value[i];
}
result
}
@@ -355,6 +359,7 @@ struct BarAndSpace<T: Default + std::cmp::PartialEq> {
space: T,
}
impl<T: Default + std::cmp::PartialEq> BarAndSpace<T> {
#[allow(dead_code)]
pub fn isValid(&self) -> bool {
self.bar != T::default() && self.space != T::default()
}
@@ -420,11 +425,11 @@ impl<const N: usize, const SUM: usize, const IS_SPARCE: bool> FixedPattern<N, SU
FixedPattern { data: *data }
}
fn as_slice(&self) -> &[PatternType] {
pub fn as_slice(&self) -> &[PatternType] {
&self.data
}
fn size(&self) -> usize {
pub fn size(&self) -> usize {
N
}

View File

@@ -44,6 +44,7 @@ pub fn GetDataMaskBit(maskIndex: u32, x: u32, y: u32, isMicro: Option<bool>) ->
))
}
#[allow(dead_code)]
pub fn GetMaskedBit(
bits: &BitMatrix,
x: u32,