Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
erion-leka committed Oct 6, 2024
1 parent d81d7db commit 7643488
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
17 changes: 9 additions & 8 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use g2p::{g2p, GaloisField};
use crate::version_db::{RSParameters, VERSION_DATA_BASE};
use crate::{BitGrid, DeQRError, DeQRResult};


g2p!(GF16, 4, modulus: 0b1_0011);
g2p!(GF256, 8, modulus: 0b1_0001_1101);

Expand Down Expand Up @@ -34,7 +33,6 @@ impl Version {
}
}


/// MetaData for a QR grid
///
/// Stores information about the size/version of given grid. Also contains
Expand All @@ -55,6 +53,12 @@ pub struct RawData {
len: usize,
}

impl Default for RawData {
fn default() -> Self {
Self::new()
}
}

impl RawData {
pub fn new() -> Self {
RawData {
Expand Down Expand Up @@ -124,7 +128,7 @@ where
}

//Getter method that extracts the raw data of a QR Code
pub fn get_raw(code: &dyn BitGrid) -> DeQRResult<(MetaData ,RawData)>{
pub fn get_raw(code: &dyn BitGrid) -> DeQRResult<(MetaData, RawData)> {
let meta = read_format(code)?;
let raw = read_data(code, &meta, false);
Ok((meta, raw))
Expand Down Expand Up @@ -567,10 +571,8 @@ fn read_data(code: &dyn BitGrid, meta: &MetaData, remove_mask: bool) -> RawData
// This allows bits to be read as they appear "physically" in the QR code or with the mask removed, reflecting the actual code.
fn read_bit(code: &dyn BitGrid, meta: &MetaData, y: usize, x: usize, remove_mask: bool) -> bool {
let mut v = code.bit(y, x) as u8;
if remove_mask {
if mask_bit(meta.mask, y, x) {
v ^= 1
}
if remove_mask && mask_bit(meta.mask, y, x) {
v ^= 1
}

v != 0
Expand All @@ -590,7 +592,6 @@ fn mask_bit(mask: u16, y: usize, x: usize) -> bool {
}
}


fn reserved_cell(version: Version, i: usize, j: usize) -> bool {
let ver = &VERSION_DATA_BASE[version.0];
let size = version.0 * 4 + 17;
Expand Down
5 changes: 1 addition & 4 deletions src/identify/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ impl SkewedGridLocation {

let c = setup_perspective(img, &group, align, grid_size)?;

Some(SkewedGridLocation {
grid_size,
c,
})
Some(SkewedGridLocation { grid_size, c })
}

/// Convert into a grid referencing the underlying image as source
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ If you have some other form of picture storage, you can use
you to define your own source for images.
"##
)]
pub use self::decode::{MetaData, Version, RawData};
pub use self::decode::{MetaData, RawData, Version};
pub(crate) use self::detect::{capstones_from_image, CapStone};
pub use self::identify::Point;
pub(crate) use self::identify::SkewedGridLocation;
Expand Down Expand Up @@ -94,7 +94,7 @@ where
Ok((meta, out))
}

pub fn get_raw_data(&self) -> DeQRResult<(MetaData, RawData)>{
pub fn get_raw_data(&self) -> DeQRResult<(MetaData, RawData)> {
crate::decode::get_raw(&self.grid)
}

Expand Down

0 comments on commit 7643488

Please sign in to comment.