Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: true
matrix:
rustc: [1.70.0, stable] # MSVR and current stable rustc
rustc: [1.85.0, stable] # MSVR and current stable rustc
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name = "qrcode"
description = "QR code encoder in Rust"
license = "MIT OR Apache-2.0"
version = "0.14.1"
edition = "2021"
rust-version = "1.70.0"
edition = "2024"
rust-version = "1.85.0"
authors = ["kennytm <kennytm@gmail.com>"]
keywords = ["qrcode"]
categories = ["encoding", "multimedia::images"]
Expand Down
2 changes: 1 addition & 1 deletion examples/encode_pic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use qrcode::render::pic;
use qrcode::QrCode;
use qrcode::render::pic;

fn main() {
let code = QrCode::new(b"01234567").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/encode_unicode.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use qrcode::render::unicode;
use qrcode::QrCode;
use qrcode::render::unicode;

fn main() {
let code = QrCode::new(b"Hello").unwrap();
Expand Down
8 changes: 2 additions & 6 deletions src/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use core::cmp::min;
extern crate test;

use crate::cast::{As, Truncate};
use crate::optimize::{total_encoded_len, Optimizer, Parser, Segment};
use crate::optimize::{Optimizer, Parser, Segment, total_encoded_len};
use crate::types::{EcLevel, Mode, QrError, QrResult, Version};

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -86,11 +86,7 @@ impl Bits {

/// Total number of bits currently pushed.
pub fn len(&self) -> usize {
if self.bit_offset == 0 {
self.data.len() * 8
} else {
(self.data.len() - 1) * 8 + self.bit_offset
}
if self.bit_offset == 0 { self.data.len() * 8 } else { (self.data.len() - 1) * 8 + self.bit_offset }
}

/// Whether there are any bits pushed.
Expand Down
2 changes: 1 addition & 1 deletion src/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ pub fn is_functional(version: Version, width: i16, x: i16, y: i16) -> bool {

#[cfg(test)]
mod all_functional_patterns_tests {
use crate::canvas::{is_functional, Canvas};
use crate::canvas::{Canvas, is_functional};
use crate::types::{EcLevel, Version};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ mod tests {
#[cfg(all(test, feature = "image"))]
mod image_tests {
use crate::{EcLevel, QrCode, Version};
use image::{load_from_memory, Luma, Rgb};
use image::{Luma, Rgb, load_from_memory};

#[test]
fn test_annex_i_qr_as_image() {
Expand Down
2 changes: 1 addition & 1 deletion src/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ pub fn total_encoded_len(segments: &[Segment], version: Version) -> usize {

#[cfg(test)]
mod optimize_tests {
use crate::optimize::{total_encoded_len, Optimizer, Segment};
use crate::optimize::{Optimizer, Segment, total_encoded_len};
use crate::types::{Mode, Version};
use alloc::vec::Vec;

Expand Down
2 changes: 1 addition & 1 deletion src/render/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use alloc::vec::Vec;
// need to keep using this macro to implement Pixel separately for each color model,
// otherwise we'll have conflicting impl with `impl Pixel for impl Element` 🤷
macro_rules! impl_pixel_for_image_pixel {
($p:ident<$s:ident>: $c:pat => $d:expr) => {
($p:ident<$s:ident>: $c:pat => $d:expr_2021) => {
impl<$s> Pixel for $p<$s>
where
$s: Primitive + 'static,
Expand Down
4 changes: 2 additions & 2 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ impl<'a, P: Pixel> Renderer<'a, P> {
pub fn min_dimensions(&mut self, width: u32, height: u32) -> &mut Self {
let quiet_zone = if self.has_quiet_zone { 2 } else { 0 } * self.quiet_zone;
let width_in_modules = self.modules_count + quiet_zone;
let unit_width = (width + width_in_modules - 1) / width_in_modules;
let unit_height = (height + width_in_modules - 1) / width_in_modules;
let unit_width = width.div_ceil(width_in_modules);
let unit_height = height.div_ceil(width_in_modules);
self.module_dimensions(unit_width, unit_height)
}

Expand Down
10 changes: 3 additions & 7 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,7 @@ impl Version {

/// The number of bits needed to encode the mode indicator.
pub fn mode_bits_count(self) -> usize {
if let Self::Micro(a) = self {
(a - 1).as_usize()
} else {
4
}
if let Self::Micro(a) = self { (a - 1).as_usize() } else { 4 }
}

/// Checks whether is version refers to a Micro QR code.
Expand Down Expand Up @@ -262,8 +258,8 @@ impl Mode {
/// i.e. half the total size of bytes.
pub const fn data_bits_count(self, raw_data_len: usize) -> usize {
match self {
Self::Numeric => (raw_data_len * 10 + 2) / 3,
Self::Alphanumeric => (raw_data_len * 11 + 1) / 2,
Self::Numeric => (raw_data_len * 10).div_ceil(3),
Self::Alphanumeric => (raw_data_len * 11).div_ceil(2),
Self::Byte => raw_data_len * 8,
Self::Kanji => raw_data_len * 13,
}
Expand Down
Loading