Skip to content

Commit

Permalink
moved to the correct place the ser type bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
zommiommy committed Feb 22, 2025
1 parent 75406c1 commit 5461a99
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions epserde-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,20 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
colon_token: token::Colon::default(),
bounds: bounds_ser,
}));

// the serialized type of the field has to implement TypeHash and ReprHash
let mut bounds_ser_sertype = Punctuated::new();
bounds_ser_sertype.push(syn::parse_quote!(epserde::traits::TypeHash));
bounds_ser_sertype.push(syn::parse_quote!(epserde::traits::ReprHash));
where_clause_ser
.predicates
.push(WherePredicate::Type(PredicateType {
lifetimes: None,
bounded_ty: syn::parse_quote!(
<#ty as epserde::ser::SerializeInner>::SerType
),
colon_token: token::Colon::default(),
bounds: bounds_ser_sertype,
}));
// add that every struct field has to implement DeserializeInner
let mut bounds_des = Punctuated::new();
bounds_des.push(syn::parse_quote!(epserde::deser::DeserializeInner));
Expand Down Expand Up @@ -412,20 +425,6 @@ pub fn epserde_derive(input: TokenStream) -> TokenStream {
colon_token: token::Colon::default(),
bounds: t.bounds.clone(),
}));

let mut bounds_ser_sertype = Punctuated::new();
bounds_ser_sertype.push(syn::parse_quote!(epserde::traits::TypeHash));
bounds_ser_sertype.push(syn::parse_quote!(epserde::traits::ReprHash));
where_clause_ser
.predicates
.push(WherePredicate::Type(PredicateType {
lifetimes: None,
bounded_ty: syn::parse_quote!(
<#ty as epserde::ser::SerializeInner>::SerType
),
colon_token: token::Colon::default(),
bounds: bounds_ser_sertype,
}));
}
});

Expand Down

0 comments on commit 5461a99

Please sign in to comment.