Refactor how we handle trait bounds in style_derive

For the traits we derive which methods don't depend on associated types (i.e.
all of them but ToAnimatedValue and ToComputedValue), we now add trait bounds
for the actual field types directly, instead of bounding the type parameters.
This commit is contained in:
Anthony Ramine 2017-08-25 19:58:49 +02:00
parent 13d47ba69a
commit 04ad28b564
8 changed files with 75 additions and 58 deletions

View file

@ -30,9 +30,7 @@ pub fn derive(input: syn::DeriveInput) -> quote::Tokens {
} else {
let mut sum = quote!();
sum.append_separated(this_info.iter().zip(&other_info).map(|(this, other)| {
where_clause.predicates.push(
cg::where_predicate(this.field.ty.clone(), trait_path),
);
where_clause.add_trait_bound(this.field.ty.clone());
quote! {
::values::distance::ComputeSquaredDistance::compute_squared_distance(#this, #other)?
}