Merge rust-bitcoin/rust-bitcoin#2471: units: Implement ops::Neg for SignedAmount
7d538c830d
units: Implement ops::Neg for SignedAmount (Tobin C. Harding) Pull request description: Its useful to be able to do `let x = -btc_amount;` Implement `core::ops::Neg for SignedAmount`, returning a `SignedAmount`. Fix: #2470 ACKs for top commit: Kixunil: ACK7d538c830d
apoelstra: ACK7d538c830d
Tree-SHA512: 168808c34513ccf7773ba03abe9375f3bed0fa92b320af5538620142552fecda671b75295a8ba6720f1aead3c722869d8dcffeeaab565c370973d2bcb8b59d1b
This commit is contained in:
commit
bac493153a
|
@ -1328,6 +1328,12 @@ impl ops::DivAssign<i64> for SignedAmount {
|
||||||
fn div_assign(&mut self, rhs: i64) { *self = *self / rhs }
|
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 {
|
impl FromStr for SignedAmount {
|
||||||
type Err = ParseError;
|
type Err = ParseError;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue