Skip to content

Not working with recent yew-0.21.0 #389

Open
@goodidea-kp

Description

@goodidea-kp

Describe the Bug

A clear and concise description of what the bug is.

Steps to Reproduce

  1. Go to 'examples/file-hash'
  2. change Cargo.toml to set yew-0.21
  3. cargo build

Expected Behavior

no errors

Actual Behavior

or[E0277]: expected a FnOnce<(&_,)> closure, found ()
--> examples/file-hash/src/bin/example_file_hash_app.rs:28:13
|
18 | use_memo(
| -------- required by a bound introduced by this call
...
28 | (),
| ^^ expected an FnOnce<(&_,)> closure, found ()
|
= help: the trait for<'a> FnOnce<(&'a _,)> is not implemented for ()
note: required by a bound in yew::use_memo
--> ..../.cargo/registry/src/index.crates.io-6f17d22bba15001f/yew-0.21.0/src/functional/hooks/use_memo.rs:77:8
|
74 | pub fn use_memo<T, F, D>(deps: D, f: F) -> Rc
| -------- required by a bound in this function
...
77 | F: FnOnce(&D) -> T,
| ^^^^^^^^^^^^^^^ required by this bound in use_memo

error[E0277]: can't compare [closure@examples/file-hash/src/bin/example_file_hash_app.rs:19:13: 19:21] with [closure@examples/file-hash/src/bin/example_file_hash_app.rs:19:13: 19:21]
--> examples/file-hash/src/bin/example_file_hash_app.rs:19:13
|
18 | use_memo(
| -------- required by a bound introduced by this call
19 | / move || {
20 | | HashWorker::spawner()
21 | | .callback(move |o| {
22 | | calculating.set(false);
... |
26 | | .spawn_with_loader("/example_file_hash_worker_loader.js")
27 | | },
| |
____________^ no implementation for [closure@examples/file-hash/src/bin/example_file_hash_app.rs:19:13: 19:21] == [closure@examples/file-hash/src/bin/example_file_hash_app.rs:19:13: 19:21]
|
= help: the trait PartialEq is not implemented for closure [closure@examples/file-hash/src/bin/example_file_hash_app.rs:19:13: 19:21]
note: required by a bound in yew::use_memo
--> ...../.cargo/registry/src/index.crates.io-6f17d22bba15001f/yew-0.21.0/src/functional/hooks/use_memo.rs:78:18
|
74 | pub fn use_memo<T, F, D>(deps: D, f: F) -> Rc
| -------- required by a bound in this function
...
78 | D: 'static + PartialEq,
| ^^^^^^^^^ required by this bound in use_memo

error[E0277]: expected a Fn<(_, &_)> closure, found ()
--> examples/file-hash/src/bin/example_file_hash_app.rs:45:13
|
35 | use_callback(
| ------------ required by a bound introduced by this call
...
45 | (),
| ^^ expected an Fn<(_, &_)> closure, found ()
|
= help: the trait for<'a> Fn<(_, &'a _)> is not implemented for ()
note: required by a bound in yew::use_callback
--> .....cargo/registry/src/index.crates.io-6f17d22bba15001f/yew-0.21.0/src/functional/hooks/use_callback.rs:67:8
|
63 | pub fn use_callback<IN, OUT, F, D>(deps: D, f: F) -> Callback<IN, OUT>
| ------------ required by a bound in this function
...
67 | F: Fn(IN, &D) -> OUT + 'static,
| ^^^^^^^^^^^^^^^^^ required by this bound in use_callback

error[E0282]: type annotations needed for Rc<T>
--> examples/file-hash/src/bin/example_file_hash_app.rs:14:9
|
14 | let worker = {
| ^^^^^^
...
42 | worker.send(input);
| ---- type must be known at this point
|
help: consider giving worker an explicit type, where the type for type parameter T is specified
|
14 | let worker: Rc = {
| +++++++

error[E0277]: can't compare [closure@examples/file-hash/src/bin/example_file_hash_app.rs:36:13: 36:32] with [closure@examples/file-hash/src/bin/example_file_hash_app.rs:36:13: 36:32]
--> examples/file-hash/src/bin/example_file_hash_app.rs:36:13
|
35 | use_callback(
| ------------ required by a bound introduced by this call
36 | / move |e: Event, i| {
37 | | let el: HtmlInputElement = e.target_unchecked_into();
38 | | if let Some(f) = el.files().and_then(|m| m.item(0)) {
39 | | calculating.set(true);
... |
43 | | }
44 | | },
| |
____________^ no implementation for [closure@examples/file-hash/src/bin/example_file_hash_app.rs:36:13: 36:32] == [closure@examples/file-hash/src/bin/example_file_hash_app.rs:36:13: 36:32]
|
= help: the trait PartialEq is not implemented for closure [closure@examples/file-hash/src/bin/example_file_hash_app.rs:36:13: 36:32]
note: required by a bound in yew::use_callback
--> /Users/kostya/.cargo/registry/src/index.crates.io-6f17d22bba15001f/yew-0.21.0/src/functional/hooks/use_callback.rs:68:8
|
63 | pub fn use_callback<IN, OUT, F, D>(deps: D, f: F) -> Callback<IN, OUT>
| ------------ required by a bound in this function
...
68 | D: PartialEq + 'static,
| ^^^^^^^^^ required by this bound in use_callback

Some errors have detailed explanations: E0277, E0282.
For more information about an error, try rustc --explain E0277.
error: could not compile example-file-hash (bin "example_file_hash_app") due to 5 previous errors
warning: build failed, waiting for other jobs to finish...

I changed a little cargo.toml like that:

gloo-worker = { path = "../../crates/worker" }
serde = "1.0.188"
web-sys = { version = "0.3.64", features = ["File", "Blob", "ReadableStream"] }
wasm-bindgen-futures = { version = "0.4" }
wasm-streams = "0.3.0"
wasm-bindgen = "0.2.87"
futures = "0.3.28"
sha2 = "0.10.8"
console_error_panic_hook = "0.1.7"
yew = { version = "0.21.0", features = ["csr"] }
serde-wasm-bindgen = "0.6.0"
js-sys = "0.3.63"
hex = "0.4.3"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions