bigint: use full cmp results for checked_sub
This commit is contained in:
parent
4a8752274c
commit
c9e15aef2d
|
@ -971,10 +971,11 @@ impl CheckedAdd for BigUint {
|
|||
impl CheckedSub for BigUint {
|
||||
#[inline]
|
||||
fn checked_sub(&self, v: &BigUint) -> Option<BigUint> {
|
||||
if *self < *v {
|
||||
return None;
|
||||
match self.cmp(v) {
|
||||
Less => None,
|
||||
Equal => Some(Zero::zero()),
|
||||
Greater => Some(self.sub(v)),
|
||||
}
|
||||
return Some(self.sub(v));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue