diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 15828c2..ef51dbf 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,9 +12,11 @@ env: jobs: build: runs-on: ubuntu-latest + env: + RUSTFLAGS: "--deny warnings" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install wasm32-unknown-unknown target run: rustup target add wasm32-unknown-unknown @@ -53,7 +55,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install wasm32-unknown-unknown target run: rustup target add wasm32-unknown-unknown @@ -70,7 +72,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Tests - name: Run tests @@ -80,8 +82,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Typos - name: typos-action uses: crate-ci/typos@v1.0.4 + - name: format + run: cargo fmt --all -- --check diff --git a/benches/qr.rs b/benches/qr.rs index fffd4ec..727f94c 100644 --- a/benches/qr.rs +++ b/benches/qr.rs @@ -2,7 +2,7 @@ use std::time::Duration; use criterion::*; -use fast_qr::{QRBuilder, QRCode}; +use fast_qr::QRBuilder; fn bench_fastqr_qrcode(c: &mut Criterion) { let bytes: &[u8] = b"https://example.com/"; @@ -60,31 +60,5 @@ fn bench_fastqr_qrcode(c: &mut Criterion) { } } -fn bench_mask(c: &mut Criterion) { - let mut group = c.benchmark_group("mask"); - group.measurement_time(Duration::from_secs(10)); - group.sample_size(200); - - use fast_qr::datamasking::Mask; - - let mut mat = black_box(QRCode::default(177)); - for (mask, id) in [ - (Mask::Checkerboard, "checkerboard"), - (Mask::HorizontalLines, "horizontal_lines"), - (Mask::VerticalLines, "vertical_lines"), - (Mask::DiagonalLines, "diagonal_lines"), - (Mask::LargeCheckerboard, "large_checkerboard"), - (Mask::Fields, "fields"), - (Mask::Diamonds, "diamonds"), - (Mask::Meadow, "meadow"), - ] { - group.bench_function(id, |b| { - b.iter(|| fast_qr::datamasking::mask(&mut mat, mask)) - }); - } - - group.finish(); -} - criterion_group!(benches, bench_fastqr_qrcode); criterion_main!(benches); diff --git a/src/convert/image.rs b/src/convert/image.rs index b4b953d..629d0f7 100644 --- a/src/convert/image.rs +++ b/src/convert/image.rs @@ -22,8 +22,7 @@ //! # } //! ``` -use std::error::Error; -use std::fmt::{Formatter, Write}; +use std::fmt::Formatter; use std::io; use crate::QRCode; @@ -61,7 +60,7 @@ impl std::fmt::Display for ImageError { match self { ImageError::IoError(io_err) => f.write_str(io_err.to_string().as_str()), ImageError::ImageError(error) => f.write_str(error.as_str()), - ImageError::EncodingError(error) => f.write_str(error.as_str()) + ImageError::EncodingError(error) => f.write_str(error.as_str()), } } } diff --git a/src/version.rs b/src/version.rs index 0784f06..b5c9ff3 100644 --- a/src/version.rs +++ b/src/version.rs @@ -630,6 +630,7 @@ impl Version { /// # Panics /// Function panics if `n` is not included in `(21..=177).step_by(4)` #[must_use] + #[cfg(any(test, feature = "svg", feature = "image", debug_assertions))] pub(crate) const fn from_n(n: usize) -> Self { use Version::{ V01, V02, V03, V04, V05, V06, V07, V08, V09, V10, V11, V12, V13, V14, V15, V16, V17,