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

wasm_bindgen on async fn doesn't accept same types that it does on regular fn #2541

Open
RReverser opened this issue Apr 29, 2021 · 1 comment
Labels

Comments

@RReverser
Copy link
Member

Describe the Bug

Currently #[wasm_bindgen] on async fn seems to only accept types that are Into<JsValue>, but many wasm-bindgen types are only IntoWasmAbi, making it hard to convert synchronous code into asynchronous.

Steps to Reproduce

Try to compile code like following:

use wasm_bindgen::Clamped;

#[wasm_bindgen]
pub fn foo() -> Clamped<Vec<u8>> {
  Clamped(vec![])
}

#[wasm_bindgen]
pub async fn foo() -> Clamped<Vec<u8>> {
  Clamped(vec![])
}

Expected Behavior

Both functions compile successfully and generate their bindings.

Actual Behavior

Second function fails to compile due to:

   | #[wasm_bindgen]
   | ^^^^^^^^^^^^^^^ the trait `From<Clamped<Vec<u8>>>` is not implemented for `JsValue`
@RReverser RReverser added the bug label Apr 29, 2021
@t-moe
Copy link

t-moe commented May 3, 2024

For fellow googlers. This is halfway fixed in #3630

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

2 participants