Merge rust-bitcoin/rust-bitcoin#4500: refactor: Use map combinator instead of match

642c414f56 refactor: Use map combinator instead of match (yancy)

Pull request description:

  Use map combinator instead of match

ACKs for top commit:
  apoelstra:
    ACK 642c414f56b03222d25fb9f11260029c5ffb6a9a; successfully ran local tests
  tcharding:
    ACK 642c414f56

Tree-SHA512: b107315bb3ac944b71b2aa0de60005e5c9cfd2affda725e795dae9e4c190a5ccabf657211199bd2e884aed63e5335ffe79281e9060025103e14d5c7604f229d1
This commit is contained in:
merge-script 2025-05-14 01:46:29 +00:00
commit 4e094d6e81
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 4 additions and 6 deletions

View File

@ -786,12 +786,10 @@ pub fn effective_value(
) -> NumOpResult<SignedAmount> {
let weight = input_weight_prediction.total_weight();
let fee = match fee_rate.to_fee(weight) {
NumOpResult::Valid(x) => x.to_signed(),
NumOpResult::Error(e) => return NumOpResult::Error(e)
};
value.to_signed() - fee // Cannot overflow.
fee_rate
.to_fee(weight)
.map(Amount::to_signed)
.and_then(|fee| value.to_signed() - fee) // Cannot overflow.
}
/// Predicts the weight of a to-be-constructed transaction.