Move impl Div and Rem into nonzero_integer macro
This commit is contained in:
parent
3de0af1a4d
commit
81e1a7c6b5
@ -201,6 +201,8 @@ fn from_str(src: &str) -> Result<Self, Self::Err> {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
nonzero_integer_impl_div_rem!($Ty $signedness $Int);
|
||||
};
|
||||
}
|
||||
|
||||
@ -275,9 +277,12 @@ pub const fn trailing_zeros(self) -> u32 {
|
||||
NonZeroIsize(usize), -1isize;
|
||||
}
|
||||
|
||||
macro_rules! nonzero_integers_div {
|
||||
( $( $Ty: ident($Int: ty); )+ ) => {
|
||||
$(
|
||||
macro_rules! nonzero_integer_impl_div_rem {
|
||||
($Ty:ident signed $Int:ty) => {
|
||||
// nothing for signed ints
|
||||
};
|
||||
|
||||
($Ty:ident unsigned $Int:ty) => {
|
||||
#[stable(feature = "nonzero_div", since = "1.51.0")]
|
||||
impl Div<$Ty> for $Int {
|
||||
type Output = $Int;
|
||||
@ -302,17 +307,7 @@ fn rem(self, other: $Ty) -> $Int {
|
||||
unsafe { crate::intrinsics::unchecked_rem(self, other.get()) }
|
||||
}
|
||||
}
|
||||
)+
|
||||
}
|
||||
}
|
||||
|
||||
nonzero_integers_div! {
|
||||
NonZeroU8(u8);
|
||||
NonZeroU16(u16);
|
||||
NonZeroU32(u32);
|
||||
NonZeroU64(u64);
|
||||
NonZeroU128(u128);
|
||||
NonZeroUsize(usize);
|
||||
};
|
||||
}
|
||||
|
||||
// A bunch of methods for unsigned nonzero types only.
|
||||
|
Loading…
Reference in New Issue
Block a user