rust-bitcoin-unsafe-fast/units/src
merge-script 551b52c7d1
Merge rust-bitcoin/rust-bitcoin#4348: refactor: Replace fold with try_fold
812c21e2e4 refactor: Replace fold with try_fold (yancy)

Pull request description:

  The and_then combinator performs a kind of bitwise and operation on two Option types here.  This is useful since the `checked` arithmetic returns an option thereby accumulating Option types.  Therefore, either the checked arithmetic operation performs the addition of the unwrapped accumulator, or it returns None.

  Instead of using `and_then` use the provided `try_fold` method which will short circuit on `None` when the checked arithmetic is used.  Also, simplify the staring condition using `Amount:ZERO` since this is logically equivalent to using the first value if one exists.

  Lastly, by using the built in `try_fold`, it's possible the performance will be improved by making use of the short circuit ability instead of evaluating each item even when the accumulator holds a None type.

ACKs for top commit:
  apoelstra:
    ACK 812c21e2e4a868046b44728c1a6209a866452820; successfully ran local tests
  tcharding:
    ACK 812c21e2e4

Tree-SHA512: 1cfcd4fa28e2b59daf3744bb5f654f65eb9853c5a36f747cb0859783e7e46c1d02ccb296612b75f7cca10782979ce052cd670c0f23c1030e0a347000d1f6df83
2025-04-16 13:56:34 +00:00
..
amount refactor: Replace fold with try_fold 2025-04-15 08:21:11 -05:00
fee_rate units: Use 100 column width in rustdoc comments 2025-04-08 14:25:04 +10:00
locktime chore: remove needless question mark 2025-03-29 01:00:06 +08:00
block.rs Use impl_add/sub_assign for block interval 2025-03-03 13:16:10 +11:00
fee.rs Add impls for NumOpResult div and mul 2025-04-14 11:32:24 +10:00
internal_macros.rs units: Fix internal docs 2025-04-07 12:14:12 +10:00
lib.rs units: Improve crate level docs 2025-04-14 14:33:26 +10:00
parse.rs chore: remove needless question mark 2025-03-29 01:00:06 +08:00
result.rs units: Enable differentiating div-by-zero 2025-04-08 09:04:30 +10:00
time.rs Add test to BlockTime to kill mutants 2025-03-26 09:36:42 +00:00
weight.rs Merge rust-bitcoin/rust-bitcoin#4174: Improve weight 2025-03-06 15:58:59 +00:00