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 {
|
impl CheckedSub for BigUint {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn checked_sub(&self, v: &BigUint) -> Option<BigUint> {
|
fn checked_sub(&self, v: &BigUint) -> Option<BigUint> {
|
||||||
if *self < *v {
|
match self.cmp(v) {
|
||||||
return None;
|
Less => None,
|
||||||
|
Equal => Some(Zero::zero()),
|
||||||
|
Greater => Some(self.sub(v)),
|
||||||
}
|
}
|
||||||
return Some(self.sub(v));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue