Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evi/workflow improv #45

Merged
merged 4 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -70,7 +72,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# Tests
- name: Run tests
Expand All @@ -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/[email protected]
- name: format
run: cargo fmt --all -- --check
28 changes: 1 addition & 27 deletions benches/qr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down Expand Up @@ -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);
5 changes: 2 additions & 3 deletions src/convert/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
//! # }
//! ```

use std::error::Error;
use std::fmt::{Formatter, Write};
use std::fmt::Formatter;
use std::io;

use crate::QRCode;
Expand Down Expand Up @@ -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()),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down