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

Incompatibility with image 0.25.0 #62

Closed
andrewweston opened this issue Mar 12, 2024 · 3 comments · Fixed by #63
Closed

Incompatibility with image 0.25.0 #62

andrewweston opened this issue Mar 12, 2024 · 3 comments · Fixed by #63

Comments

@andrewweston
Copy link

Upgrading to image 0.25.0 results in a compatibility issue between the image::Pixel trait implementation and the render::Pixel trait:

// issue with image::Luma<u8>'s implementation of Pixel
let img_buf = qr_code.render::<image::Luma<u8>>().build();

The most notable image change is the switch from the use of #[repr(C)] to #[repr(transparent)] in the Pixel trait implementation:

#[derive(PartialEq, Eq, Clone, Debug, Copy, Hash)]
#[repr(transparent)]  // <- previously #[repr(C)]
#[allow(missing_docs)]
pub struct $ident<T> (pub [T; $channels]);  
@JunaYa
Copy link

JunaYa commented Mar 13, 2024

dependencies

qrcode = "0.13.0"
image = "0.25.0"

use code

    // Encode some data into bits.
    let code = QrCode::new(b"01234567").unwrap();

    // Render the bits into an image.
    let image = code.render::<Luma<u8>>().build();

    // Save the image.
    image.save("/tmp/qrcode.png").unwrap();

error info

error[E0277]: the trait bound `Luma<u8>: Element` is not satisfied
   --> src/main.rs:44:31
    |
44  |     let image = code.render::<Luma<u8>>().build();
    |                      ------   ^^^^^^^^ the trait `Element` is not implemented for `Luma<u8>`
    |                      |
    |                      required by a bound introduced by this call
    |
    = help: the following other types implement trait `Element`:
              char
              &'a str
    = note: required for `Luma<u8>` to implement `qrcode::render::Pixel`
note: required by a bound in `QrCode::render`
   --> /Users/aya/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/qrcode-0.13.0/src/lib.rs:249:22
    |
249 |     pub fn render<P: Pixel>(&self) -> Renderer<P> {
    |                      ^^^^^ required by this bound in `QrCode::render`

@kennytm
Copy link
Owner

kennytm commented Mar 13, 2024

The current qrcode package depends on image = "0.24.0", which is semver-incompatible with 0.25.0, and thus image/*0.24*/::Luma and image/*0.25*/::Luma are considered distinct types. It has nothing to do with #[repr] or whatever.

Yes we know what is going on, you will have to wait for qrcode to upgrade its image dependency to 0.25 first.

@robatipoor
Copy link

robatipoor commented Mar 13, 2024

I tried compiling this crate with image version 0.25.0. Fortunately, there were no errors or deprecations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants