mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-27 12:06:14 +03:00
d5b81595ec
First added in #161 this never ended up panning out, so let's remove the experimental suport which isn't actually used by anything today and hold off on any other changes until an RFC happens.
56 lines
1.2 KiB
Rust
56 lines
1.2 KiB
Rust
use wasm_bindgen_test::*;
|
|
use wasm_bindgen::prelude::*;
|
|
use self::inner::ColorWithCustomValues;
|
|
|
|
#[wasm_bindgen(module = "tests/wasm/enums.js")]
|
|
extern {
|
|
fn js_c_style_enum();
|
|
fn js_c_style_enum_with_custom_values();
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
pub enum Color {
|
|
Green,
|
|
Yellow,
|
|
Red,
|
|
}
|
|
|
|
pub mod inner {
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
#[wasm_bindgen]
|
|
pub enum ColorWithCustomValues {
|
|
Green = 21,
|
|
Yellow = 34,
|
|
Red,
|
|
}
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
pub fn enum_cycle(color: Color) -> Color {
|
|
match color {
|
|
Color::Green => Color::Yellow,
|
|
Color::Yellow => Color::Red,
|
|
Color::Red => Color::Green,
|
|
}
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
pub fn enum_with_custom_values_cycle(color: ColorWithCustomValues) -> ColorWithCustomValues {
|
|
match color {
|
|
ColorWithCustomValues::Green => ColorWithCustomValues::Yellow,
|
|
ColorWithCustomValues::Yellow => ColorWithCustomValues::Red,
|
|
ColorWithCustomValues::Red => ColorWithCustomValues::Green,
|
|
}
|
|
}
|
|
|
|
#[wasm_bindgen_test]
|
|
fn c_style_enum() {
|
|
js_c_style_enum();
|
|
}
|
|
|
|
#[wasm_bindgen_test]
|
|
fn c_style_enum_with_custom_values() {
|
|
js_c_style_enum_with_custom_values();
|
|
}
|