Skip to content

Add .into() to the generated code for async fns#3919

Merged
daxpedda merged 2 commits intowasm-bindgen:mainfrom
MOZGIII:fix-async-into
Jul 28, 2024
Merged

Add .into() to the generated code for async fns#3919
daxpedda merged 2 commits intowasm-bindgen:mainfrom
MOZGIII:fix-async-into

Conversation

@MOZGIII
Copy link
Copy Markdown
Contributor

@MOZGIII MOZGIII commented Apr 10, 2024

Without this I am getting an error for declarations like these:

    #[wasm_bindgen(method, getter)]
    pub async fn closed(this: &WebTransport) -> WebTransportCloseInfo;
    #[wasm_bindgen(method, getter, catch)]
    pub async fn closed(this: &WebTransport) -> Result<WebTransportCloseInfo, JsValue>;

I have tried to also create a test for this to catch regressions, but was unable to figure out where to put it.

Test

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen]
    #[derive(Debug, Clone)]
    pub type WebTransportCloseInfo;
}

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen]
    #[derive(Debug, Clone)]
    pub type WebTransport;

    #[wasm_bindgen(method, getter, catch)]
    pub async fn closed(this: &WebTransport) -> Result<WebTransportCloseInfo, JsValue>;
}

@MOZGIII MOZGIII changed the title Add into to the generated code for async fns Add .into() to the generated code for async fns Apr 10, 2024
Copy link
Copy Markdown
Member

@daxpedda daxpedda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this hasn't come up until now.

Comment thread crates/backend/src/codegen.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants