reverse condition in `uN::checked_sub` · rust-lang/rust@7fde730

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Commit 7fde730

committed

reverse condition in uN::checked_sub

1 parent fe03fb9 commit 7fde730

File tree

1 file changed

+

3

-

3

lines changed

1 file changed

+

3

-

3

lines changed

Lines changed: 3 additions & 3 deletions

Original file line numberDiff line numberDiff line change

@@ -584,11 +584,11 @@ macro_rules! uint_impl {

584584

// Thus, rather than using `overflowing_sub` that produces a wrapping

585585

// subtraction, check it ourself so we can use an unchecked one.

586586
587-

if self >= rhs {

587+

if self < rhs {

588+

None

589+

} else {

588590

// SAFETY: just checked this can't overflow

589591

Some(unsafe { intrinsics::unchecked_sub(self, rhs) })

590-

} else {

591-

None

592592

}

593593

}

594594

0 commit comments

Comments

 (0)