Merge rust-bitcoin/rust-bitcoin#4320: units: Do trivial docs fixes
da69e636a9
units: Use 100 column width in rustdoc comments (Tobin C. Harding)53c6ae4d40
units: Remove expect from rustdoc example (Tobin C. Harding) Pull request description: A couple of quick docs fixes while trying to polish `units`. ACKs for top commit: apoelstra: ACK da69e636a9d21e602289062279ed5ebc6b1429b6; successfully ran local tests Tree-SHA512: acfbec90b0327850b882c5e1b1e7eaadbf0a09a30dcc46529386ea419ed74846a678a5980f5706f8d280f30ec6f6d06af2db8f0e1748523b15ad47a654caee4b
This commit is contained in:
commit
c5b1b31963
|
@ -30,8 +30,8 @@ impl Amount {
|
||||||
/// # use bitcoin_units::{amount, Amount, FeeRate, Weight};
|
/// # use bitcoin_units::{amount, Amount, FeeRate, Weight};
|
||||||
/// let amount = Amount::from_sat(10)?;
|
/// let amount = Amount::from_sat(10)?;
|
||||||
/// let weight = Weight::from_wu(300);
|
/// let weight = Weight::from_wu(300);
|
||||||
/// let fee_rate = amount.checked_div_by_weight_ceil(weight).expect("Division by weight failed");
|
/// let fee_rate = amount.checked_div_by_weight_ceil(weight);
|
||||||
/// assert_eq!(fee_rate, FeeRate::from_sat_per_kwu(34));
|
/// assert_eq!(fee_rate, Some(FeeRate::from_sat_per_kwu(34)));
|
||||||
/// # Ok::<_, amount::OutOfRangeError>(())
|
/// # Ok::<_, amount::OutOfRangeError>(())
|
||||||
/// ```
|
/// ```
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
@ -140,10 +140,9 @@ impl FeeRate {
|
||||||
|
|
||||||
/// Checked weight multiplication.
|
/// Checked weight multiplication.
|
||||||
///
|
///
|
||||||
/// Computes the absolute fee amount for a given [`Weight`] at this fee rate.
|
/// Computes the absolute fee amount for a given [`Weight`] at this fee rate. When the resulting
|
||||||
/// When the resulting fee is a non-integer amount, the amount is rounded up,
|
/// fee is a non-integer amount, the amount is rounded up, ensuring that the transaction fee is
|
||||||
/// ensuring that the transaction fee is enough instead of falling short if
|
/// enough instead of falling short if rounded down.
|
||||||
/// rounded down.
|
|
||||||
///
|
///
|
||||||
/// Returns [`None`] if overflow occurred.
|
/// Returns [`None`] if overflow occurred.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
@ -197,10 +196,9 @@ crate::internal_macros::impl_op_for_references! {
|
||||||
impl Weight {
|
impl Weight {
|
||||||
/// Checked fee rate multiplication.
|
/// Checked fee rate multiplication.
|
||||||
///
|
///
|
||||||
/// Computes the absolute fee amount for a given [`FeeRate`] at this weight.
|
/// Computes the absolute fee amount for a given [`FeeRate`] at this weight. When the resulting
|
||||||
/// When the resulting fee is a non-integer amount, the amount is rounded up,
|
/// fee is a non-integer amount, the amount is rounded up, ensuring that the transaction fee is
|
||||||
/// ensuring that the transaction fee is enough instead of falling short if
|
/// enough instead of falling short if rounded down.
|
||||||
/// rounded down.
|
|
||||||
///
|
///
|
||||||
/// Returns [`None`] if overflow occurred.
|
/// Returns [`None`] if overflow occurred.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
|
|
@ -12,8 +12,8 @@ use arbitrary::{Arbitrary, Unstructured};
|
||||||
|
|
||||||
/// Represents fee rate.
|
/// Represents fee rate.
|
||||||
///
|
///
|
||||||
/// This is an integer newtype representing fee rate in `sat/kwu`. It provides protection against mixing
|
/// This is an integer newtype representing fee rate in `sat/kwu`. It provides protection against
|
||||||
/// up the types as well as basic formatting features.
|
/// mixing up the types as well as basic formatting features.
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||||
pub struct FeeRate(u64);
|
pub struct FeeRate(u64);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue