Skip to content

Commit

Permalink
reverse condition in uN::checked_sub
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-shrimp committed May 12, 2024
1 parent fe03fb9 commit 7fde730
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,11 @@ macro_rules! uint_impl {
// 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
}
}

Expand Down

0 comments on commit 7fde730

Please sign in to comment.