Skip to content

Commit 81e1a7c

Browse files
committed
Move impl Div and Rem into nonzero_integer macro
1 parent 3de0af1 commit 81e1a7c

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

library/core/src/num/nonzero.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ macro_rules! nonzero_integer {
201201
})
202202
}
203203
}
204+
205+
nonzero_integer_impl_div_rem!($Ty $signedness $Int);
204206
};
205207
}
206208

@@ -275,9 +277,12 @@ nonzero_leading_trailing_zeros! {
275277
NonZeroIsize(usize), -1isize;
276278
}
277279

278-
macro_rules! nonzero_integers_div {
279-
( $( $Ty: ident($Int: ty); )+ ) => {
280-
$(
280+
macro_rules! nonzero_integer_impl_div_rem {
281+
($Ty:ident signed $Int:ty) => {
282+
// nothing for signed ints
283+
};
284+
285+
($Ty:ident unsigned $Int:ty) => {
281286
#[stable(feature = "nonzero_div", since = "1.51.0")]
282287
impl Div<$Ty> for $Int {
283288
type Output = $Int;
@@ -302,17 +307,7 @@ macro_rules! nonzero_integers_div {
302307
unsafe { crate::intrinsics::unchecked_rem(self, other.get()) }
303308
}
304309
}
305-
)+
306-
}
307-
}
308-
309-
nonzero_integers_div! {
310-
NonZeroU8(u8);
311-
NonZeroU16(u16);
312-
NonZeroU32(u32);
313-
NonZeroU64(u64);
314-
NonZeroU128(u128);
315-
NonZeroUsize(usize);
310+
};
316311
}
317312

318313
// A bunch of methods for unsigned nonzero types only.

0 commit comments

Comments
 (0)