reverse condition in uN::checked_sub

This commit is contained in:
ivan-shrimp 2024-05-12 11:29:24 +08:00
parent fe03fb9569
commit 7fde7308bf

View File

@ -584,11 +584,11 @@ pub const fn checked_sub(self, rhs: Self) -> Option<Self> {
// Thus, rather than using `overflowing_sub` that produces a wrapping
// subtraction, check it ourself so we can use an unchecked one.
if self >= rhs {
if self < rhs {
None
} else {
// SAFETY: just checked this can't overflow
Some(unsafe { intrinsics::unchecked_sub(self, rhs) })
} else {
None
}
}