Skip to content

Update documentation on extern C async #3250

@matthiasgeihs

Description

@matthiasgeihs

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.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions