reverse condition in uN::checked_sub · rust-lang/rust@7fde730 (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Commit 7fde730

reverse condition in uN::checked_sub

File tree

1 file changed

lines changed

1 file changed

lines changed

Original file line number Diff line number Diff line change
@@ -584,11 +584,11 @@ macro_rules! uint_impl {
584 584 // Thus, rather than using `overflowing_sub` that produces a wrapping
585 585 // subtraction, check it ourself so we can use an unchecked one.
586 586
587 -if self >= rhs {
587 +if self < rhs {
588 +None
589 +} else {
588 590 // SAFETY: just checked this can't overflow
589 591 Some(unsafe { intrinsics::unchecked_sub(self, rhs) })
590 -} else {
591 -None
592 592 }
593 593 }
594 594