@@ -209,16 +209,14 @@ macro_rules! result_body {
209
209
paste:: paste! {
210
210
let mut result = $self;
211
211
result. [ <$name _assign>] ( & $( $deref) ?$other) ;
212
- result
212
+ return result;
213
213
}
214
214
}
215
215
}
216
216
217
217
macro_rules! assign_body {
218
218
( $name: ident, $self: ident, $other: ident, $( $deref: tt) ?) => {
219
- paste:: paste! {
220
- $self. [ <$name _assign>] ( & $( $deref) ?$other) ;
221
- }
219
+ $self. $name( & $( $deref) ?$other)
222
220
}
223
221
}
224
222
@@ -237,7 +235,8 @@ macro_rules! impl_ops_from_ref {
237
235
(
238
236
$name: ident,
239
237
$body: ident
240
- $d( , { $d output: ident} ) ?
238
+ $d( , { $d output: ident $d self_return: ident} ) ?
239
+ $d( , [ $d self_mut: tt] ) ?
241
240
$d( , <$d lifetime: tt $d mut : tt $d deref: tt>) ?
242
241
) => {
243
242
paste:: paste! {
@@ -254,7 +253,7 @@ macro_rules! impl_ops_from_ref {
254
253
$d( type $d output = Self ; ) ?
255
254
256
255
#[ inline]
257
- fn $name( self , other: Self ) -> Self {
256
+ fn $name( $d ( & $d self_mut ) ? self , other: $d ( & $d lifetime ) ?$d ( $d mut ) ? Self ) $d ( -> $d self_return ) ? {
258
257
$body!( $name, self , other, $d( $d deref) ?) ;
259
258
}
260
259
}
@@ -292,25 +291,25 @@ macro_rules! impl_ops_from_ref {
292
291
293
292
instantiate!( $) ;
294
293
295
- ops!( add, result_body, { Output } ) ;
296
- ops!( add, result_body, { Output } , <' a mut * >) ;
297
- ops!( sub, result_body, { Output } ) ;
298
- ops!( sub, result_body, { Output } , <' a mut * >) ;
294
+ ops!( add, result_body, { Output Self } ) ;
295
+ ops!( add, result_body, { Output Self } , <' a mut * >) ;
296
+ ops!( sub, result_body, { Output Self } ) ;
297
+ ops!( sub, result_body, { Output Self } , <' a mut * >) ;
299
298
300
- ops!( mul, result_body, { Output } ) ;
301
- ops!( mul, result_body, { Output } , <' a mut * >) ;
302
- ops!( div, result_body, { Output } ) ;
303
- ops!( div, result_body, { Output } , <' a mut * >) ;
299
+ ops!( mul, result_body, { Output Self } ) ;
300
+ ops!( mul, result_body, { Output Self } , <' a mut * >) ;
301
+ ops!( div, result_body, { Output Self } ) ;
302
+ ops!( div, result_body, { Output Self } , <' a mut * >) ;
304
303
305
- ops!( add_assign, assign_body) ;
306
- ops!( add_assign, assign_body, <' a mut * >) ;
307
- ops!( sub_assign, assign_body) ;
308
- ops!( sub_assign, assign_body, <' a mut * >) ;
304
+ ops!( add_assign, assign_body, [ mut ] ) ;
305
+ ops!( add_assign, assign_body, [ mut ] , <' a mut * >) ;
306
+ ops!( sub_assign, assign_body, [ mut ] ) ;
307
+ ops!( sub_assign, assign_body, [ mut ] , <' a mut * >) ;
309
308
310
- ops!( mul_assign, assign_body) ;
311
- ops!( mul_assign, assign_body, <' a mut * >) ;
312
- ops!( div_assign, assign_body) ;
313
- ops!( div_assign, assign_body, <' a mut * >) ;
309
+ ops!( mul_assign, assign_body, [ mut ] ) ;
310
+ ops!( mul_assign, assign_body, [ mut ] , <' a mut * >) ;
311
+ ops!( div_assign, assign_body, [ mut ] ) ;
312
+ ops!( div_assign, assign_body, [ mut ] , <' a mut * >) ;
314
313
315
314
use core:: iter:: { Sum , Product } ;
316
315
0 commit comments