Merge rust-bitcoin/rust-bitcoin#3360: Improve documentation test in merkle_tree

9fc2c2a5b1 Improve documentation test in merkle_tree (Jiri Jakes)

Pull request description:

  Removes unnecessary usage of vector and adds a missing assert. Closes #3353.

  Note: Kixunil in the [referred comment](https://github.com/rust-bitcoin/rust-bitcoin/pull/3288#discussion_r1756514494) wondered about missing 'unused variable' warning. It seems that rustdoc [adds](https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#pre-processing-examples) allows to the documentation tests. However, these warnings [can be enabled](https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#showing-warnings-in-doctests) on module level. Do we want that? I tried to enable and there are already some occurrences of unused variables and imports. Caveat: it seems that we can't deny warnings on that, only print the warnings to stdout with `--show-output`.

ACKs for top commit:
  apoelstra:
    ACK 9fc2c2a5b1 successfully ran local tests
  tcharding:
    ACK 9fc2c2a5b1

Tree-SHA512: 776177a903a6d2dcd25ba5cc8ef0db5f38d2cdb061975d3f7cc179369796af17f70e9dfe8bb4f49ff0c6df85d7e7c9d5b1d1d386a7508eee6b7dec17b7093d80
This commit is contained in:
merge-script 2024-09-17 11:55:32 +00:00
commit bb4a9dec52
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 2 additions and 2 deletions

View File

@ -7,11 +7,11 @@
//! ```
//! # use bitcoin::Txid;
//! # use bitcoin::merkle_tree::{MerkleNode as _, TxMerkleNode};
//! # use bitcoin::hashes::Hash;
//! # let tx1 = Txid::from_byte_array([0xAA; 32]); // Arbitrary dummy hash values.
//! # let tx2 = Txid::from_byte_array([0xFF; 32]);
//! let tx_hashes = vec![tx1, tx2]; // All the hashes we wish to merkelize.
//! let tx_hashes = [tx1, tx2]; // All the hashes we wish to merkelize.
//! let root = TxMerkleNode::calculate_root(tx_hashes.into_iter());
//! assert!(root.is_some());
//! ```
mod block;