diff --git a/crates/wasm-bindgen-macro/src/lib.rs b/crates/wasm-bindgen-macro/src/lib.rs index e9eb4a3a..410552f3 100755 --- a/crates/wasm-bindgen-macro/src/lib.rs +++ b/crates/wasm-bindgen-macro/src/lib.rs @@ -369,6 +369,18 @@ impl ToTokens for ast::ImportType { self.obj.to_js_ref() } } + + impl From<::wasm_bindgen::JsValue> for #name { + fn from(obj: ::wasm_bindgen::JsValue) -> #name { + #name { obj } + } + } + + impl From<#name> for ::wasm_bindgen::JsValue { + fn from(obj: #name) -> ::wasm_bindgen::JsValue { + obj.obj + } + } }).to_tokens(tokens); } }