You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create async methods on my struct. I looked at #1858 but that issue is closed without an explanation why the code below doesn't work. Is there any workaround?
use std::future::Future;use wasm_bindgen::prelude::*;#[wasm_bindgen]pubstructA{}#[wasm_bindgen]implA{#[wasm_bindgen(constructor)]pubfnnew() -> Self{A{}}pubfntest(&mutself) -> implFuture<Output = Result<JsValue,JsValue>>{Ok(JsValue::from(true))}}
error[E0667]: `impl Trait` is not allowed in path parameters
--> src/lib.rs:7:1
|
7 | #[wasm_bindgen]
| ^^^^^^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> src/lib.rs:7:1
|
7 | #[wasm_bindgen]
| ^^^^^^^^^^^^^^^
error[E0277]: the trait bound `impl std::future::Future: wasm_bindgen::convert::traits::IntoWasmAbi` is not satisfied
--> src/lib.rs:7:1
|
7 | #[wasm_bindgen]
| ^^^^^^^^^^^^^^^ the trait `wasm_bindgen::convert::traits::IntoWasmAbi` is not implemented for `impl std::future::Future`
|
= note: required because of the requirements on the impl of `wasm_bindgen::convert::traits::ReturnWasmAbi` for `impl std::future::Future`
error: aborting due to 3 previous errors
The text was updated successfully, but these errors were encountered:
Definitely agreed that we should try to improve the error here! It may be somewhat difficult to do so, but @Pauan is also correct in that you'll need to return a Promise instead of an impl Trait
I'm trying to create async methods on my struct. I looked at #1858 but that issue is closed without an explanation why the code below doesn't work. Is there any workaround?
The text was updated successfully, but these errors were encountered: