Skip to content

Commit

Permalink
fix: where clause for From conversion trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantamis committed Apr 12, 2024
1 parent 24434dd commit 9c4ef85
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tsify-next-macros/src/wasm_bindgen.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use proc_macro2::TokenStream;
use quote::quote;
use syn::parse_quote;
use syn::{parse_quote, WhereClause};

use crate::{container::Container, decl::Decl};

Expand Down Expand Up @@ -94,6 +94,8 @@ fn expand_into_wasm_abi(cont: &Container) -> TokenStream {

let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

let serde_where_clause = WhereClause { where_token: parse_quote!(where), predicates: parse_quote!(#ident #ty_generics: #serde_path::Serialize)};

quote! {
impl #impl_generics IntoWasmAbi for #ident #ty_generics #where_clause {
type Abi = <JsType as IntoWasmAbi>::Abi;
Expand All @@ -111,7 +113,7 @@ fn expand_into_wasm_abi(cont: &Container) -> TokenStream {
}
}

impl #impl_generics From<#ident #ty_generics> for JsValue {
impl #impl_generics From<#ident #ty_generics> for JsValue #serde_where_clause {
#[inline]
fn from(value: #ident #ty_generics) -> Self {
value.into_js().unwrap_throw().into()
Expand Down

0 comments on commit 9c4ef85

Please sign in to comment.