plotters-rs/plotters-piston

Error in executing realtime rendering example

k-jayanth opened this issue · 4 comments

I am new to rust and when i was trying to execute this example its giving error at this line

while let Some(_) = draw_piston_window(&mut window, |b| {

the error was

   --> src/main.rs:151:44
    |
151 |     while let Some(_) = draw_piston_window(&mut window, |b| {
    |                                            ^^^^^^^^^^^ expected struct `piston_window::PistonWindow`, found struct `PistonWindow`
    |
    = note: expected mutable reference `&mut piston_window::PistonWindow`
               found mutable reference `&mut PistonWindow`
    = note: perhaps two different versions of crate `piston_window` are being used?

i am using the following versions
plotters-piston = "0.3.0"
plotters-backend = "0.3.0"
piston_window = "0.120.0"
systemstat = "0.1.8"
plotters = "0.3.1"

please help me solve this

It looks like the upgrade of piston_window to 0.120.0 caused this problem, putting in 0.112.0 works just fine for me.

The cargo package has not been updated. use:
plotters-piston = { git = "https://github.com/plotters-rs/plotters-piston" }
until the owner updates cargo

Current form of this issue:

error[E0308]: mismatched types
   --> src/main.rs:123:44
    |
123 |     while let Some(_) = draw_piston_window(&mut window, |b| {
    |                         ------------------ ^^^^^^^^^^^ expected `PistonWindow`, found a different `PistonWindow`
    |                         |
    |                         arguments to this function are incorrect
    |
    = note: `PistonWindow` and `PistonWindow` have similar names, but are actually distinct types
note: `PistonWindow` is defined in crate `piston_window`
   --> /home/dnelson/.cargo/registry/src/index.crates.io-6f17d22bba15001f/piston_window-0.131.0/src/prelude.rs:62:1
    |
62  | pub struct PistonWindow<W: Window = GlutinWindow> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `PistonWindow` is defined in crate `piston_window`
   --> /home/dnelson/.cargo/registry/src/index.crates.io-6f17d22bba15001f/piston_window-0.120.0/src/lib.rs:151:1
    |
151 | pub struct PistonWindow<W: Window = GlutinWindow> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: function defined here
   --> /home/dnelson/.cargo/git/checkouts/plotters-piston-a7252f5dfd01c74f/7293411/src/backend.rs:197:8
    |
197 | pub fn draw_piston_window<F: FnOnce(PistonBackend) -> Result<(), Box<dyn std::error...
    |        ^^^^^^^^^^^^^^^^^^

Downgrading fixes this (see #10 ).

Just ran into this issue and downgrading piston_window to 0.112.0 allowed the example to compile, but interestingly mousing over the graph causes a panic which crashes the example.

Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/plot-test`
thread 'main' panicked at library/core/src/panicking.rs:220:5:
attempted to leave type `platform::platform::x11::util::input::PointerState<'_>` uninitialized, which is invalid
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
[1]    784962 IOT instruction (core dumped)  cargo run