amount: Improve docs on div by weight
Make an effort to improve the docs on `Amount::checked_div_by_weight` and `ops::Div<weight> for Amount`.
This commit is contained in:
parent
2b4a61739a
commit
41c80cc476
|
@ -235,7 +235,7 @@ impl Amount {
|
|||
///
|
||||
/// Be aware that integer division loses the remainder if no exact division
|
||||
/// can be made. This method rounds up ensuring the transaction fee-rate is
|
||||
/// sufficient. If you wish to round-down, use the unchecked version instead.
|
||||
/// sufficient. If you wish to round down use `amount / weight`.
|
||||
///
|
||||
/// [`None`] is returned if an overflow occurred.
|
||||
#[cfg(feature = "alloc")]
|
||||
|
|
|
@ -211,6 +211,10 @@ impl Mul<Weight> for FeeRate {
|
|||
impl Div<Weight> for Amount {
|
||||
type Output = FeeRate;
|
||||
|
||||
/// Truncating integer division.
|
||||
///
|
||||
/// This is likely the wrong thing for a user dividing an amount by a weight. Consider using
|
||||
/// `checked_div_by_weight` instead.
|
||||
fn div(self, rhs: Weight) -> Self::Output { FeeRate(self.to_sat() * 1000 / rhs.to_wu()) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue