Rollup merge of #87910 - iago-lito:mark_unsafe_nonzero_arithmetics_as_const, r=joshtriplett
Mark unsafe methods NonZero*::unchecked_(add|mul) as const. Now that https://github.com/rust-lang/rfcs/pull/3016 has landed, these two unstable `std` function can be marked `const`, according to this detail of #84186.
This commit is contained in:
commit
e500f1c1e9
@ -379,7 +379,7 @@ macro_rules! nonzero_unsigned_operations {
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[inline]
|
||||
pub unsafe fn unchecked_add(self, other: $Int) -> $Ty {
|
||||
pub const unsafe fn unchecked_add(self, other: $Int) -> $Ty {
|
||||
// SAFETY: The caller ensures there is no overflow.
|
||||
unsafe { $Ty::new_unchecked(self.get().unchecked_add(other)) }
|
||||
}
|
||||
@ -750,7 +750,7 @@ macro_rules! nonzero_unsigned_signed_operations {
|
||||
/// ```
|
||||
#[unstable(feature = "nonzero_ops", issue = "84186")]
|
||||
#[inline]
|
||||
pub unsafe fn unchecked_mul(self, other: $Ty) -> $Ty {
|
||||
pub const unsafe fn unchecked_mul(self, other: $Ty) -> $Ty {
|
||||
// SAFETY: The caller ensures there is no overflow.
|
||||
unsafe { $Ty::new_unchecked(self.get().unchecked_mul(other.get())) }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user