File tree 3 files changed +19
-1
lines changed
3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -1456,7 +1456,7 @@ impl ToTokens for ast::Enum {
1456
1456
type Error = #wasm_bindgen:: JsValue ;
1457
1457
1458
1458
fn try_from( value: #wasm_bindgen:: JsValue )
1459
- -> #wasm_bindgen:: __rt:: std:: result:: Result <Self , Self :: Error > {
1459
+ -> #wasm_bindgen:: __rt:: std:: result:: Result <Self , <#enum_name as #wasm_bindgen :: __rt :: core :: convert :: TryFrom < JsValue >> :: Error > {
1460
1460
let js = f64 :: try_from( & value) ? as u32 ;
1461
1461
1462
1462
#wasm_bindgen:: __rt:: std:: result:: Result :: Ok (
Original file line number Diff line number Diff line change @@ -38,3 +38,7 @@ exports.js_expect_enum_none = a => {
38
38
exports . js_renamed_enum = b => {
39
39
assert . strictEqual ( wasm . JsRenamedEnum . B , b ) ;
40
40
} ;
41
+
42
+ exports . js_enum_with_error_variant = ( ) => {
43
+ assert . strictEqual ( wasm . EnumWithErrorVariant . Error , 2 ) ;
44
+ } ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ extern "C" {
10
10
fn js_expect_enum ( x : Color , y : Option < Color > ) ;
11
11
fn js_expect_enum_none ( x : Option < Color > ) ;
12
12
fn js_renamed_enum ( b : RenamedEnum ) ;
13
+ fn js_enum_with_error_variant ( ) ;
13
14
}
14
15
15
16
#[ wasm_bindgen]
@@ -71,6 +72,14 @@ pub fn handle_optional_enums(x: Option<Color>) -> Option<Color> {
71
72
x
72
73
}
73
74
75
+ #[ wasm_bindgen]
76
+ #[ derive( Copy , Clone ) ]
77
+ pub enum EnumWithErrorVariant {
78
+ OK ,
79
+ Warning ,
80
+ Error ,
81
+ }
82
+
74
83
#[ wasm_bindgen_test]
75
84
fn test_optional_enums ( ) {
76
85
use self :: Color :: * ;
@@ -95,3 +104,8 @@ fn test_optional_enum_values() {
95
104
fn test_renamed_enum ( ) {
96
105
js_renamed_enum ( RenamedEnum :: B ) ;
97
106
}
107
+
108
+ #[ wasm_bindgen_test]
109
+ fn test_enum_with_error_variant ( ) {
110
+ js_enum_with_error_variant ( ) ;
111
+ }
You can’t perform that action at this time.
0 commit comments