Skip to content

Commit

Permalink
Fix Add with generics
Browse files Browse the repository at this point in the history
  • Loading branch information
yanganto committed Aug 9, 2024
1 parent 0ad6210 commit 8559864
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions struct-patch-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl Patch {

#[cfg(feature = "add")]
let add_impl = quote! {
impl core::ops::Add<#name #generics> for #struct_name #generics #where_clause {
impl #generics core::ops::Add<#name #generics> for #struct_name #generics #where_clause {
type Output = Self;

fn add(mut self, rhs: #name #generics) -> Self {
Expand All @@ -111,10 +111,10 @@ impl Patch {
}
}

impl core::ops::Add<#struct_name #generics> for #name #generics #where_clause {
impl #generics core::ops::Add<#struct_name #generics> for #name #generics #where_clause {
type Output = #struct_name #generics;

fn add(mut self, rhs: #struct_name #generics) -> #struct_name #where_clause {
fn add(mut self, rhs: #struct_name #generics) -> #struct_name #generics {
let mut rhs = rhs;
rhs.apply(self);
rhs
Expand Down
3 changes: 2 additions & 1 deletion struct-patch/examples/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ fn main() {
assert_eq!(item.field_int, 7);
assert_eq!(item.field_string, "");

#[cfg(feature = "add")] {
#[cfg(feature = "add")]
{
let another_patch = ItemPatch {
field_complete: None,
field_int: None,
Expand Down

0 comments on commit 8559864

Please sign in to comment.