mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
clippy fix
This commit is contained in:
@@ -410,27 +410,20 @@ impl Default for BitArray {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Vec<u8>> for BitArray {
|
impl From<BitArray> for Vec<u8> {
|
||||||
fn into(self) -> Vec<u8> {
|
fn from(value: BitArray) -> Self {
|
||||||
let mut array = vec![0; self.getSizeInBytes()];
|
let mut array = vec![0; value.getSizeInBytes()];
|
||||||
self.toBytes(0, &mut array, 0, self.getSizeInBytes());
|
value.toBytes(0, &mut array, 0, value.getSizeInBytes());
|
||||||
array
|
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 {
|
impl From<BitArray> for Vec<bool> {
|
||||||
fn into(self) -> Vec<bool> {
|
fn from(value: BitArray) -> Self {
|
||||||
let mut array = vec![false; self.size];
|
let mut array = vec![false; value.size];
|
||||||
|
|
||||||
for (pixel, element) in array.iter_mut().enumerate().take(self.size) {
|
for (pixel, element) in array.iter_mut().enumerate().take(value.size) {
|
||||||
*element = self.get(pixel);
|
*element = value.get(pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
array
|
array
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ impl PatternRow {
|
|||||||
self.0.len()
|
self.0.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.0.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn into_pattern_view(&self) -> PatternView {
|
pub fn into_pattern_view(&self) -> PatternView {
|
||||||
PatternView::new(self)
|
PatternView::new(self)
|
||||||
}
|
}
|
||||||
@@ -324,21 +328,21 @@ impl std::ops::Index<i32> for PatternView<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Into<Vec<PatternType>> for &PatternView<'a> {
|
impl<'a> From<&PatternView<'a>> for Vec<PatternType> {
|
||||||
fn into(self) -> Vec<PatternType> {
|
fn from(value: &PatternView<'a>) -> Self {
|
||||||
let mut v = vec![PatternType::default(); self.count];
|
let mut v = vec![PatternType::default(); value.count];
|
||||||
for i in 0..self.count {
|
for i in 0..value.count {
|
||||||
v[i] = self[i];
|
v[i] = value[i];
|
||||||
}
|
}
|
||||||
v
|
v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, const LEN: usize> Into<[PatternType; LEN]> for &PatternView<'a> {
|
impl<'a, const LEN: usize> From<&PatternView<'a>> for [PatternType; LEN] {
|
||||||
fn into(self) -> [PatternType; LEN] {
|
fn from(value: &PatternView<'a>) -> Self {
|
||||||
let mut result = [PatternType::default(); LEN];
|
let mut result = [PatternType::default(); LEN];
|
||||||
for i in 0..self.count {
|
for i in 0..value.count {
|
||||||
result[i] = self[i];
|
result[i] = value[i];
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
@@ -355,6 +359,7 @@ struct BarAndSpace<T: Default + std::cmp::PartialEq> {
|
|||||||
space: T,
|
space: T,
|
||||||
}
|
}
|
||||||
impl<T: Default + std::cmp::PartialEq> BarAndSpace<T> {
|
impl<T: Default + std::cmp::PartialEq> BarAndSpace<T> {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn isValid(&self) -> bool {
|
pub fn isValid(&self) -> bool {
|
||||||
self.bar != T::default() && self.space != T::default()
|
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 }
|
FixedPattern { data: *data }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_slice(&self) -> &[PatternType] {
|
pub fn as_slice(&self) -> &[PatternType] {
|
||||||
&self.data
|
&self.data
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size(&self) -> usize {
|
pub fn size(&self) -> usize {
|
||||||
N
|
N
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ pub fn GetDataMaskBit(maskIndex: u32, x: u32, y: u32, isMicro: Option<bool>) ->
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn GetMaskedBit(
|
pub fn GetMaskedBit(
|
||||||
bits: &BitMatrix,
|
bits: &BitMatrix,
|
||||||
x: u32,
|
x: u32,
|
||||||
|
|||||||
Reference in New Issue
Block a user