units: Implement ops::Neg for SignedAmount

Its useful to be able to do `let x = -btc_amount;`

Implement `core::ops::Neg for SignedAmount`, returning a `SignedAmount`.

Fix: #2470
This commit is contained in:
Tobin C. Harding 2024-02-12 13:04:26 +11:00
parent 53461f71c9
commit 7d538c830d
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 6 additions and 0 deletions

View File

@ -1328,6 +1328,12 @@ impl ops::DivAssign<i64> for SignedAmount {
fn div_assign(&mut self, rhs: i64) { *self = *self / rhs }
}
impl ops::Neg for SignedAmount {
type Output = Self;
fn neg(self) -> Self::Output { Self(self.0.neg()) }
}
impl FromStr for SignedAmount {
type Err = ParseError;