Express `i64::MAX + 1` as `i64::MIN.unsigned_abs()`
This better conveys the intention that we're checking the lower bound.
This commit is contained in:
parent
b562a18914
commit
54cbbf804f
|
@ -975,8 +975,8 @@ impl SignedAmount {
|
||||||
// (negative, amount)
|
// (negative, amount)
|
||||||
(false, sat) if sat > i64::MAX as u64 => Err(ParseAmountError::TooBig),
|
(false, sat) if sat > i64::MAX as u64 => Err(ParseAmountError::TooBig),
|
||||||
(false, sat) => Ok(SignedAmount(sat as i64)),
|
(false, sat) => Ok(SignedAmount(sat as i64)),
|
||||||
(true, sat) if sat == i64::MAX as u64 + 1 => Ok(SignedAmount(i64::MIN)),
|
(true, sat) if sat == i64::MIN.unsigned_abs() => Ok(SignedAmount(i64::MIN)),
|
||||||
(true, sat) if sat > i64::MAX as u64 + 1 => Err(ParseAmountError::TooBig),
|
(true, sat) if sat > i64::MIN.unsigned_abs() => Err(ParseAmountError::TooBig),
|
||||||
(true, sat) => Ok(SignedAmount(-(sat as i64))),
|
(true, sat) => Ok(SignedAmount(-(sat as i64))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue