Wasm-bindgen: `#[wasm_bindgen(skip)]` for impls functions

Created on 25 Sep 2019  路  2Comments  路  Source: rustwasm/wasm-bindgen

Motivation

Add way to skip pub functions in #[wasm_bindgen] impls when generating JS glue.

Proposed Solution

#[wasm_bindgen]
impl Foo {
    #[wasm_bindgen(skip)]
    pub fn bar(&self) -> i32 {
        7
    }
}

Alternatives

Skip pub (crate/self/anything) functions.

enhancement

Most helpful comment

You can accomplish this by simply not using #[wasm_bindgen]:

impl Foo {
    pub fn bar(&self) -> i32 {
        7
    }
}

#[wasm_bindgen]
impl Foo {
    // functions that you want to send to JS
}

This works because you can have many impl blocks for a single type.

All 2 comments

You can accomplish this by simply not using #[wasm_bindgen]:

impl Foo {
    pub fn bar(&self) -> i32 {
        7
    }
}

#[wasm_bindgen]
impl Foo {
    // functions that you want to send to JS
}

This works because you can have many impl blocks for a single type.

@Pauan ,

Thanks! Closing then.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MarcAntoine-Arnaud picture MarcAntoine-Arnaud  路  3Comments

alexcrichton picture alexcrichton  路  3Comments

kyren picture kyren  路  3Comments

pauldorehill picture pauldorehill  路  3Comments

aschampion picture aschampion  路  4Comments