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

Returning Vec<String> from an async function fails to compile #3793

Open
FredrikNoren opened this issue Jan 18, 2024 · 0 comments
Open

Returning Vec<String> from an async function fails to compile #3793

FredrikNoren opened this issue Jan 18, 2024 · 0 comments
Labels

Comments

@FredrikNoren
Copy link

Describe the Bug

This code:

#[wasm_bindgen]
pub async fn get_strings() -> Vec<String> {
    vec!["hello".to_string(), "world".to_string()]
}

Expected Behavior

Should compile,

Actual Behavior

But gives the following compilation error:

the trait bound `wasm_bindgen::JsValue: From<Vec<std::string::String>>` is not satisfied
the following other types implement trait `From<T>`:
  <wasm_bindgen::JsValue as From<bool>>
  <wasm_bindgen::JsValue as From<isize>>
  <wasm_bindgen::JsValue as From<i8>>
  <wasm_bindgen::JsValue as From<i16>>
  <wasm_bindgen::JsValue as From<i32>>
  <wasm_bindgen::JsValue as From<i64>>
  <wasm_bindgen::JsValue as From<i128>>
  <wasm_bindgen::JsValue as From<usize>>
and 100 others
required for `Vec<std::string::String>` to implement `Into<wasm_bindgen::JsValue>`
required for `Vec<std::string::String>` to implement `IntoJsResult`

Additional Context

wasm-bindgen = "0.2"

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

No branches or pull requests

1 participant