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

"Iterating Over Any JavaScript Object" example does not compile #1109

Closed
sandromario opened this issue Dec 12, 2018 · 4 comments
Closed

"Iterating Over Any JavaScript Object" example does not compile #1109

sandromario opened this issue Dec 12, 2018 · 4 comments

Comments

@sandromario
Copy link

The following code from the example "Iterating Over Any JavaScript Object" (https://rustwasm.github.io/wasm-bindgen/reference/iterating-over-js-values.html#iterating-over-uanyu-javascript-object-that-implements-the-iterator-protocol) does not compile:

let iterator = match js_sys::try_iter(some_iterable)?.ok_or_else(|| {
        "need to pass iterable JS values!".into()
    })?;

This is the output I get:

   |
86 |     let iterator = match js_sys::try_iter(some_iterable)?.ok_or_else(|| {
   |                    -----
   |                    |
   |                    while parsing this match expression
   |                    help: try removing this `match`
87 |         "need to pass iterable JS values!".into()
88 |     })?;
   |        ^ expected one of `.`, `?`, `{`, or an operator here
@alexcrichton
Copy link
Contributor

Oops, thanks for the report!

@sandromario
Copy link
Author

sandromario commented Dec 12, 2018

There's one more:

error[E0599]: no method named `is_f64` found for type `wasm_bindgen::JsValue` in the current scope

@sandromario
Copy link
Author

And also, if I comment the is_f64 line out, I get:

error[E0282]: type annotations needed
  --> src/lib.rs:86:53
   |
86 |     let iterator = js_sys::try_iter(some_iterable)?.ok_or_else(|| {
   |                                                     ^^^^^^^^^^ cannot infer type for `E`

@alexcrichton
Copy link
Contributor

Oops, should be fixed now too!

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

No branches or pull requests

2 participants