Skip to content

Commit

Permalink
Merge rust-bitcoin#3681: hashes: Documents C-QUESTION-MARK
Browse files Browse the repository at this point in the history
91268bb Examples use ?, not try!, not unwrap (Jamil Lambert, PhD)

Pull request description:

  To conform to Rust API guidelines in Issue rust-bitcoin#3633 examples should use ?, not try!, not unwrap (C-QUESTION-MARK).

  The examples were originally labelled `## Commonly used operations`, change the label to `# Examples`.
  Replace `unwrap()` with `expect()` since these cases cannot error.

  Two uses of `unwrap()` have been left since they are in a set of three writes with an engine that can not error and the first case uses `expect()` with the relevant error message.

ACKs for top commit:
  tcharding:
    ACK 91268bb
  sanket1729:
    ACK 91268bb
  apoelstra:
    ACK 91268bb; successfully ran local tests

Tree-SHA512: 4c7836b2e8d67ac5d6f85229ca9ad3c9c5f0f1dc7062bda398c48ef72fd6bb965effee313151f70c86bd7cebda78a651cc12b2d59bc331d689089cf17b8c3dc8
  • Loading branch information
apoelstra committed Nov 29, 2024
2 parents 85d1eb8 + 91268bb commit 230b9e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hashes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! This library implements the hash functions needed by Bitcoin. As an ancillary thing, it exposes
//! hexadecimal serialization and deserialization, since these are needed to display hashes.
//!
//! ## Commonly used operations
//! # Examples
//!
//! Hashing a single byte slice or a string:
//!
Expand All @@ -26,7 +26,7 @@
//!
//! let mut reader: &[u8] = b"hello"; // In real code, this could be a `File` or `TcpStream`.
//! let mut engine = Sha256::engine();
//! std::io::copy(&mut reader, &mut engine).unwrap();
//! std::io::copy(&mut reader, &mut engine).expect("engine writes don't error");
//! let _hash = Sha256::from_engine(engine);
//! # }
//! ```
Expand Down

0 comments on commit 230b9e5

Please sign in to comment.