-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Motivation
Was getting some unexpected behavior when working with extern "C"
in combination with async
.
#[wasm_bindgen]
extern "C" {
async fn f() -> String;
}
This does not compile.
mismatched types
expected struct `std::string::String`, found struct `wasm_bindgen::JsValue`
Currently it seems like we cannot have return type different than JsValue
. (Implementing From<JsValue>
doesn't help.) However, there appears to be no information on this in the official documentation.
After some searching, I found some background info on this in the PR implementing the functionality: #2196 (comment). Basically it seems that only return types JsValue
is supported.
Proposed Solution
Add relevant information about allowed return types in async extern C to official documentation.
(Might create a PR for this myself if I find time, but wanted to document here now.)