Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#3297): Allow variant skip #3496

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

erwanvivien
Copy link
Contributor

@erwanvivien erwanvivien commented Jun 25, 2023

Provides a way to avoid having only C-Style enums allowed with #[wasm_bindgen] by allowing user to omit an enum Variant, it's then at the user discretion to use #[cfg] directives to reflect this

Can be seen in the example:

#[wasm_bindgen]
pub enum Operation {
    INCREMENT,

    #[cfg(not(target_arch = "wasm32"))]
    #[wasm_bindgen(skip)]
    CUSTOM(fn(i32) -> i32),
}

provides a way to avoid having this error:
only C-Style enums allowed with #[wasm_bindgen]

```rust
\#[wasm_bindgen]
pub enum Operation {
    INCREMENT,

    #[cfg(not(target_arch = "wasm32"))]
    #[wasm_bindgen(skip)]
    CUSTOM(fn(i32) -> i32),
}
```
@erwanvivien
Copy link
Contributor Author

As discussed with Daxpedda on Discord, this is not a good idea.

@daxpedda daxpedda added the waiting for author Waiting for author to respond label Jun 26, 2023
@daxpedda daxpedda self-assigned this Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for author Waiting for author to respond
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants