Skip to content

Commit e52556c

Browse files
committed
Fix some errors, cargo +nightly test passes.
1 parent a809a67 commit e52556c

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

ff/src/fields/arithmetic.rs

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,14 @@ macro_rules! result_body {
209209
paste::paste! {
210210
let mut result = $self;
211211
result.[<$name _assign>](&$($deref)?$other);
212-
result
212+
return result;
213213
}
214214
}
215215
}
216216

217217
macro_rules! assign_body {
218218
($name:ident, $self:ident, $other:ident, $($deref:tt)?) => {
219-
paste::paste! {
220-
$self.[<$name _assign>](&$($deref)?$other);
221-
}
219+
$self.$name(&$($deref)?$other)
222220
}
223221
}
224222

@@ -237,7 +235,8 @@ macro_rules! impl_ops_from_ref {
237235
(
238236
$name:ident,
239237
$body:ident
240-
$d(, {$d output:ident})?
238+
$d(, {$d output:ident $d ReturnType:ident})?
239+
$d(, [$d self_mut:tt])?
241240
$d(, <$d lifetime:tt $d mut:tt $d deref:tt>)?
242241
) => {
243242
paste::paste! {
@@ -249,19 +248,35 @@ macro_rules! impl_ops_from_ref {
249248
$type_params:
250249
$bounds$(<$($bound_params)*>)?
251250
),*
252-
> [<$name:camel>]<$d(&$d lifetime )?$d($d mut )?Self> for $type<$($type_params),*>
251+
> [<$name:camel>]<$d(&$d lifetime $d mut )?Self> for $type<$($type_params),*>
253252
{
254253
$d(type $d output = Self;)?
255254

256255
#[inline]
257-
fn $name(self, other: Self) -> Self {
256+
fn $name(
257+
$d(&$d self_mut)?self,
258+
other: $d(&$d lifetime )?$d($d mut )?Self
259+
) $d(-> $d ReturnType)? {
258260
$body!($name, self, other, $d($d deref)?);
259261
}
260262
}
261263
}
262264
}
263265
}
264266

267+
macro_rules! instantiate_ops {
268+
($d($d op:ident),*) => {
269+
paste::paste! {
270+
$d(
271+
ops!($d op, result_body, {Output Self});
272+
ops!($d op, result_body, {Output Self}, <'a mut *>);
273+
ops!([<$d op _assign>], assign_body, [mut]);
274+
ops!([<$d op _assign>], assign_body, [mut], <'a mut *>);
275+
)*
276+
}
277+
}
278+
}
279+
265280
macro_rules! iter {
266281
(
267282
$name:ident,
@@ -291,26 +306,7 @@ macro_rules! impl_ops_from_ref {
291306
}
292307

293308
instantiate!($);
294-
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 *>);
299-
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 *>);
304-
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 *>);
309-
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+
instantiate_ops!(add, sub, mul, div);
314310

315311
use core::iter::{Sum, Product};
316312

0 commit comments

Comments
 (0)