wasm-rs / async-executor

Async executor for WebAssembly
Apache License 2.0
78 stars 10 forks source link

Example fails to compile #25

Open kylebarron opened 2 years ago

kylebarron commented 2 years ago
> wasm-pack build
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
   Compiling async-executor-demo v0.1.0 (/Users/kyle/github/rust/async-executor/example)
error[E0308]: mismatched types
  --> example/src/lib.rs:71:24
   |
71 |     executor::run(Some(task1));
   |                        ^^^^^ expected struct `Task`, found struct `TaskHandle`
   |
   = note: expected struct `Task`
              found struct `TaskHandle<()>`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `async-executor-demo` due to previous error
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
> cargo --version
cargo 1.60.0 (d1fd9fe2c 2022-03-01)
> rustc --version
rustc 1.60.0 (7737e0b5c 2022-04-04)
rusxg commented 1 year ago

Still having the same issue with cargo & rustc version 1.63.0, but with a little more detailed message:

error[E0308]: mismatched types
   --> src/lib.rs:71:24
    |
71  |     executor::run(Some(task1));
    |                   ---- ^^^^^ expected struct `Task`, found struct `TaskHandle`
    |                   |
    |                   arguments to this enum variant are incorrect
    |
    = note: expected struct `Task`
               found struct `TaskHandle<()>`
rusxg commented 1 year ago

Not sure if it's the right thing to do, but the example compiles and runs successfully if I add .task() call to convert Task into TaskHandle like this:

    executor::run(Some(task1.task()));