units: Use one level of path for ops traits
Make all the `core::ops` impls in the `units` crate uniform by using a single level of path for the traits.
This commit is contained in:
parent
6ce5385914
commit
20a79da344
|
@ -2,8 +2,7 @@
|
|||
|
||||
//! Implements `FeeRate` and assoctiated features.
|
||||
|
||||
use core::fmt;
|
||||
use core::ops::{Add, AddAssign, Div, Mul, Sub, SubAssign};
|
||||
use core::{fmt, ops};
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
use arbitrary::{Arbitrary, Unstructured};
|
||||
|
@ -185,14 +184,14 @@ impl From<FeeRate> for u64 {
|
|||
fn from(value: FeeRate) -> Self { value.to_sat_per_kwu() }
|
||||
}
|
||||
|
||||
impl Add for FeeRate {
|
||||
impl ops::Add 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);
|
||||
|
||||
impl Sub for FeeRate {
|
||||
impl ops::Sub for FeeRate {
|
||||
type Output = FeeRate;
|
||||
|
||||
fn sub(self, rhs: FeeRate) -> Self::Output { FeeRate(self.0 - rhs.0) }
|
||||
|
@ -200,7 +199,7 @@ impl Sub for FeeRate {
|
|||
crate::internal_macros::impl_sub_for_references!(FeeRate);
|
||||
|
||||
/// Computes the ceiling so that the fee computation is conservative.
|
||||
impl Mul<FeeRate> for Weight {
|
||||
impl ops::Mul<FeeRate> for Weight {
|
||||
type Output = Amount;
|
||||
|
||||
fn mul(self, rhs: FeeRate) -> Self::Output {
|
||||
|
@ -208,13 +207,13 @@ impl Mul<FeeRate> for Weight {
|
|||
}
|
||||
}
|
||||
|
||||
impl Mul<Weight> for FeeRate {
|
||||
impl ops::Mul<Weight> for FeeRate {
|
||||
type Output = Amount;
|
||||
|
||||
fn mul(self, rhs: Weight) -> Self::Output { rhs * self }
|
||||
}
|
||||
|
||||
impl Div<Weight> for Amount {
|
||||
impl ops::Div<Weight> for Amount {
|
||||
type Output = FeeRate;
|
||||
|
||||
/// Truncating integer division.
|
||||
|
@ -224,19 +223,19 @@ impl Div<Weight> for Amount {
|
|||
fn div(self, rhs: Weight) -> Self::Output { FeeRate(self.to_sat() * 1000 / rhs.to_wu()) }
|
||||
}
|
||||
|
||||
impl AddAssign for FeeRate {
|
||||
impl ops::AddAssign for FeeRate {
|
||||
fn add_assign(&mut self, rhs: Self) { self.0 += rhs.0 }
|
||||
}
|
||||
|
||||
impl AddAssign<&FeeRate> for FeeRate {
|
||||
impl ops::AddAssign<&FeeRate> for FeeRate {
|
||||
fn add_assign(&mut self, rhs: &FeeRate) { self.0 += rhs.0 }
|
||||
}
|
||||
|
||||
impl SubAssign for FeeRate {
|
||||
impl ops::SubAssign for FeeRate {
|
||||
fn sub_assign(&mut self, rhs: Self) { self.0 -= rhs.0 }
|
||||
}
|
||||
|
||||
impl SubAssign<&FeeRate> for FeeRate {
|
||||
impl ops::SubAssign<&FeeRate> for FeeRate {
|
||||
fn sub_assign(&mut self, rhs: &FeeRate) { self.0 -= rhs.0 }
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
//! Implements `Weight` and associated features.
|
||||
|
||||
use core::fmt;
|
||||
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
|
||||
use core::{fmt, ops};
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
use arbitrary::{Arbitrary, Unstructured};
|
||||
|
@ -167,55 +166,55 @@ impl From<Weight> for u64 {
|
|||
fn from(value: Weight) -> Self { value.to_wu() }
|
||||
}
|
||||
|
||||
impl Add for Weight {
|
||||
impl ops::Add for Weight {
|
||||
type Output = Weight;
|
||||
|
||||
fn add(self, rhs: Weight) -> Self::Output { Weight(self.0 + rhs.0) }
|
||||
}
|
||||
|
||||
impl AddAssign for Weight {
|
||||
impl ops::AddAssign for Weight {
|
||||
fn add_assign(&mut self, rhs: Self) { self.0 += rhs.0 }
|
||||
}
|
||||
|
||||
impl Sub for Weight {
|
||||
impl ops::Sub for Weight {
|
||||
type Output = Weight;
|
||||
|
||||
fn sub(self, rhs: Weight) -> Self::Output { Weight(self.0 - rhs.0) }
|
||||
}
|
||||
|
||||
impl SubAssign for Weight {
|
||||
impl ops::SubAssign for Weight {
|
||||
fn sub_assign(&mut self, rhs: Self) { self.0 -= rhs.0 }
|
||||
}
|
||||
|
||||
impl Mul<u64> for Weight {
|
||||
impl ops::Mul<u64> for Weight {
|
||||
type Output = Weight;
|
||||
|
||||
fn mul(self, rhs: u64) -> Self::Output { Weight(self.0 * rhs) }
|
||||
}
|
||||
|
||||
impl Mul<Weight> for u64 {
|
||||
impl ops::Mul<Weight> for u64 {
|
||||
type Output = Weight;
|
||||
|
||||
fn mul(self, rhs: Weight) -> Self::Output { Weight(self * rhs.0) }
|
||||
}
|
||||
|
||||
impl MulAssign<u64> for Weight {
|
||||
impl ops::MulAssign<u64> for Weight {
|
||||
fn mul_assign(&mut self, rhs: u64) { self.0 *= rhs }
|
||||
}
|
||||
|
||||
impl Div<u64> for Weight {
|
||||
impl ops::Div<u64> for Weight {
|
||||
type Output = Weight;
|
||||
|
||||
fn div(self, rhs: u64) -> Self::Output { Weight(self.0 / rhs) }
|
||||
}
|
||||
|
||||
impl Div<Weight> for Weight {
|
||||
impl ops::Div<Weight> for Weight {
|
||||
type Output = u64;
|
||||
|
||||
fn div(self, rhs: Weight) -> Self::Output { self.to_wu() / rhs.to_wu() }
|
||||
}
|
||||
|
||||
impl DivAssign<u64> for Weight {
|
||||
impl ops::DivAssign<u64> for Weight {
|
||||
fn div_assign(&mut self, rhs: u64) { self.0 /= rhs }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue