bigint: use full cmp results for checked_sub

This commit is contained in:
Josh Stone 2015-12-15 22:31:46 -08:00
parent 4a8752274c
commit c9e15aef2d
1 changed files with 4 additions and 3 deletions

View File

@ -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));
}
}