@@ -155,7 +155,48 @@ impl Patch {
155155 } )
156156 . collect :: < Vec < _ > > ( ) ;
157157
158- #[ cfg( feature = "op" ) ]
158+ #[ cfg( all( feature = "op" , not( feature = "merge" ) ) ) ]
159+ let op_impl = quote ! {
160+ impl #generics core:: ops:: Shl <#name #generics> for #struct_name #generics #where_clause {
161+ type Output = Self ;
162+
163+ fn shl( mut self , rhs: #name #generics) -> Self {
164+ struct_patch:: traits:: Patch :: apply( & mut self , rhs) ;
165+ self
166+ }
167+ }
168+
169+ impl #generics core:: ops:: Add <Self > for #name #generics #where_clause {
170+ type Output = Self ;
171+
172+ fn add( mut self , rhs: Self ) -> Self {
173+ Self {
174+ #(
175+ #renamed_field_names: match ( self . #renamed_field_names, rhs. #renamed_field_names) {
176+ ( Some ( a) , Some ( b) ) => {
177+ #addable_handles
178+ } ,
179+ ( Some ( a) , None ) => Some ( a) ,
180+ ( None , Some ( b) ) => Some ( b) ,
181+ ( None , None ) => None ,
182+ } ,
183+ ) *
184+ #(
185+ #original_field_names: match ( self . #original_field_names, rhs. #original_field_names) {
186+ ( Some ( a) , Some ( b) ) => {
187+ #addable_handles
188+ } ,
189+ ( Some ( a) , None ) => Some ( a) ,
190+ ( None , Some ( b) ) => Some ( b) ,
191+ ( None , None ) => None ,
192+ } ,
193+ ) *
194+ }
195+ }
196+ }
197+ } ;
198+
199+ #[ cfg( feature = "merge" ) ]
159200 let op_impl = quote ! {
160201 impl #generics core:: ops:: Shl <#name #generics> for #struct_name #generics #where_clause {
161202 type Output = Self ;
@@ -166,7 +207,6 @@ impl Patch {
166207 }
167208 }
168209
169- #[ cfg( feature = "merge" ) ]
170210 impl #generics core:: ops:: Shl <#name #generics> for #name #generics #where_clause {
171211 type Output = Self ;
172212
@@ -204,6 +244,7 @@ impl Patch {
204244 }
205245 }
206246 } ;
247+
207248 #[ cfg( not( feature = "op" ) ) ]
208249 let op_impl = quote ! ( ) ;
209250
@@ -446,7 +487,7 @@ impl Field {
446487 ADDABLE => {
447488 return Err ( syn:: Error :: new (
448489 ident. span ( ) ,
449- "`addable` needs `op` feature"
490+ "`addable` needs `op` feature" ,
450491 ) ) ;
451492 }
452493 #[ cfg( feature = "op" ) ]
@@ -457,10 +498,7 @@ impl Field {
457498 }
458499 #[ cfg( not( feature = "op" ) ) ]
459500 ADD => {
460- return Err ( syn:: Error :: new (
461- ident. span ( ) ,
462- "`add` needs `op` feature"
463- ) ) ;
501+ return Err ( syn:: Error :: new ( ident. span ( ) , "`add` needs `op` feature" ) ) ;
464502 }
465503 _ => {
466504 return Err ( meta. error ( format_args ! (
0 commit comments