units: rearrange a bit of code to prep the next commit
The next commit changes a lot of code, but almost entirely by moving and indenting it. We try to do the moves here ahead of time, so it the diff for the next commit will be just deletions and indentations.
This commit is contained in:
parent
a358e79a85
commit
0dc7f6cebd
|
@ -137,18 +137,6 @@ crate::internal_macros::impl_op_for_references! {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME these two should be covered by generic impls below
|
||||
impl ops::Add<Amount> for NumOpResult<Amount> {
|
||||
type Output = NumOpResult<Amount>;
|
||||
|
||||
fn add(self, rhs: Amount) -> Self::Output { rhs + self }
|
||||
}
|
||||
impl ops::Add<&Amount> for NumOpResult<Amount> {
|
||||
type Output = NumOpResult<Amount>;
|
||||
|
||||
fn add(self, rhs: &Amount) -> Self::Output { rhs + self }
|
||||
}
|
||||
|
||||
crate::internal_macros::impl_op_for_references! {
|
||||
impl ops::Sub<Amount> for Amount {
|
||||
type Output = NumOpResult<Amount>;
|
||||
|
@ -261,7 +249,19 @@ impl ops::Rem<&u64> for &Amount {
|
|||
fn rem(self, modulus: &u64) -> Self::Output { (*self).rem(*modulus) }
|
||||
}
|
||||
|
||||
impl ops::Add for SignedAmount {
|
||||
// FIXME these two should be covered by generic impls below
|
||||
impl ops::Add<Amount> for NumOpResult<Amount> {
|
||||
type Output = NumOpResult<Amount>;
|
||||
|
||||
fn add(self, rhs: Amount) -> Self::Output { rhs + self }
|
||||
}
|
||||
impl ops::Add<&Amount> for NumOpResult<Amount> {
|
||||
type Output = NumOpResult<Amount>;
|
||||
|
||||
fn add(self, rhs: &Amount) -> Self::Output { rhs + self }
|
||||
}
|
||||
|
||||
impl ops::Add<SignedAmount> for SignedAmount {
|
||||
type Output = NumOpResult<SignedAmount>;
|
||||
|
||||
fn add(self, rhs: SignedAmount) -> Self::Output { self.checked_add(rhs).valid_or_error() }
|
||||
|
@ -289,7 +289,7 @@ impl ops::Add<&SignedAmount> for NumOpResult<SignedAmount> {
|
|||
fn add(self, rhs: &SignedAmount) -> Self::Output { rhs + self }
|
||||
}
|
||||
|
||||
impl ops::Sub for SignedAmount {
|
||||
impl ops::Sub<SignedAmount> for SignedAmount {
|
||||
type Output = NumOpResult<SignedAmount>;
|
||||
|
||||
fn sub(self, rhs: SignedAmount) -> Self::Output { self.checked_sub(rhs).valid_or_error() }
|
||||
|
|
|
@ -135,20 +135,20 @@ impl From<FeeRate> for u64 {
|
|||
fn from(value: FeeRate) -> Self { value.to_sat_per_kwu() }
|
||||
}
|
||||
|
||||
impl ops::Add for FeeRate {
|
||||
impl ops::Add<FeeRate> for FeeRate {
|
||||
type Output = FeeRate;
|
||||
|
||||
fn add(self, rhs: FeeRate) -> Self::Output { FeeRate(self.0 + rhs.0) }
|
||||
}
|
||||
crate::internal_macros::impl_add_for_references!(FeeRate);
|
||||
crate::internal_macros::impl_add_assign!(FeeRate);
|
||||
|
||||
impl ops::Sub for FeeRate {
|
||||
impl ops::Sub<FeeRate> for FeeRate {
|
||||
type Output = FeeRate;
|
||||
|
||||
fn sub(self, rhs: FeeRate) -> Self::Output { FeeRate(self.0 - rhs.0) }
|
||||
}
|
||||
crate::internal_macros::impl_sub_for_references!(FeeRate);
|
||||
crate::internal_macros::impl_add_assign!(FeeRate);
|
||||
crate::internal_macros::impl_sub_assign!(FeeRate);
|
||||
|
||||
impl core::iter::Sum for FeeRate {
|
||||
|
|
|
@ -166,20 +166,20 @@ impl From<Weight> for u64 {
|
|||
fn from(value: Weight) -> Self { value.to_wu() }
|
||||
}
|
||||
|
||||
impl ops::Add for Weight {
|
||||
impl ops::Add<Weight> for Weight {
|
||||
type Output = Weight;
|
||||
|
||||
fn add(self, rhs: Weight) -> Self::Output { Weight(self.0 + rhs.0) }
|
||||
}
|
||||
crate::internal_macros::impl_add_for_references!(Weight);
|
||||
crate::internal_macros::impl_add_assign!(Weight);
|
||||
|
||||
impl ops::Sub for Weight {
|
||||
impl ops::Sub<Weight> for Weight {
|
||||
type Output = Weight;
|
||||
|
||||
fn sub(self, rhs: Weight) -> Self::Output { Weight(self.0 - rhs.0) }
|
||||
}
|
||||
crate::internal_macros::impl_sub_for_references!(Weight);
|
||||
crate::internal_macros::impl_add_assign!(Weight);
|
||||
crate::internal_macros::impl_sub_assign!(Weight);
|
||||
|
||||
impl ops::Mul<u64> for Weight {
|
||||
|
|
Loading…
Reference in New Issue