units: Implement ops for amount types
Use the shiny new ops macros to implement the full set of `Add`, `AddAssign`, `Sub`, and `SubAssign` impls we require.
This commit is contained in:
parent
4a3aa4a08b
commit
d88306fb68
|
@ -388,10 +388,8 @@ impl ops::Add for SignedAmount {
|
||||||
self.checked_add(rhs).expect("SignedAmount addition error")
|
self.checked_add(rhs).expect("SignedAmount addition error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
crate::internal_macros::impl_add_for_references!(SignedAmount);
|
||||||
impl ops::AddAssign for SignedAmount {
|
crate::internal_macros::impl_add_assign!(SignedAmount);
|
||||||
fn add_assign(&mut self, rhs: SignedAmount) { *self = *self + rhs }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ops::Sub for SignedAmount {
|
impl ops::Sub for SignedAmount {
|
||||||
type Output = SignedAmount;
|
type Output = SignedAmount;
|
||||||
|
@ -400,10 +398,8 @@ impl ops::Sub for SignedAmount {
|
||||||
self.checked_sub(rhs).expect("SignedAmount subtraction error")
|
self.checked_sub(rhs).expect("SignedAmount subtraction error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
crate::internal_macros::impl_sub_for_references!(SignedAmount);
|
||||||
impl ops::SubAssign for SignedAmount {
|
crate::internal_macros::impl_sub_assign!(SignedAmount);
|
||||||
fn sub_assign(&mut self, rhs: SignedAmount) { *self = *self - rhs }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ops::Rem<i64> for SignedAmount {
|
impl ops::Rem<i64> for SignedAmount {
|
||||||
type Output = SignedAmount;
|
type Output = SignedAmount;
|
||||||
|
|
|
@ -457,10 +457,8 @@ impl ops::Add for Amount {
|
||||||
self.checked_add(rhs).expect("Amount addition error")
|
self.checked_add(rhs).expect("Amount addition error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
crate::internal_macros::impl_add_for_references!(Amount);
|
||||||
impl ops::AddAssign for Amount {
|
crate::internal_macros::impl_add_assign!(Amount);
|
||||||
fn add_assign(&mut self, rhs: Amount) { *self = *self + rhs }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ops::Sub for Amount {
|
impl ops::Sub for Amount {
|
||||||
type Output = Amount;
|
type Output = Amount;
|
||||||
|
@ -469,10 +467,8 @@ impl ops::Sub for Amount {
|
||||||
self.checked_sub(rhs).expect("Amount subtraction error")
|
self.checked_sub(rhs).expect("Amount subtraction error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
crate::internal_macros::impl_sub_for_references!(Amount);
|
||||||
impl ops::SubAssign for Amount {
|
crate::internal_macros::impl_sub_assign!(Amount);
|
||||||
fn sub_assign(&mut self, rhs: Amount) { *self = *self - rhs }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ops::Rem<u64> for Amount {
|
impl ops::Rem<u64> for Amount {
|
||||||
type Output = Amount;
|
type Output = Amount;
|
||||||
|
|
Loading…
Reference in New Issue