Skip to content

Not being able to compile an enum with impl #1303

Closed
@Cegard

Description

@Cegard

Hello everybody!

I'm getting the next error wehen trying to compile an enum with an impl

error: cannot shadow already defined class 'Foo' Error: Running the wasm-bindgen CLI Caused by: Running the wasm-bindgen CLI Caused by: failed to execute 'wasm-bindgen': exited with exit status: 1

like this:

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub enum Foo {
    A,
    B
}

#[wasm_bindgen]
impl Foo {
    pub fn from(f: usize) -> Option<Foo> {
        match f {
            0 => Some(Foo::A),
            1 => Some(Foo::B),
            _ => None
        }
    }
}

wasm-pack version: 0.11.0
rustc version: 1.69.0

Regards!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions