Merge rust-bitcoin/rust-bitcoin#3681: hashes: Documents C-QUESTION-MARK
91268bba67
Examples use ?, not try!, not unwrap (Jamil Lambert, PhD) Pull request description: To conform to Rust API guidelines in Issue #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: ACK91268bba67
sanket1729: ACK91268bba67
apoelstra: ACK 91268bba672d7dea9e29cccfa83f3b34df27fe91; successfully ran local tests Tree-SHA512: 4c7836b2e8d67ac5d6f85229ca9ad3c9c5f0f1dc7062bda398c48ef72fd6bb965effee313151f70c86bd7cebda78a651cc12b2d59bc331d689089cf17b8c3dc8
This commit is contained in:
commit
230b9e5ca0
|
@ -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:
|
||||
//!
|
||||
|
@ -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);
|
||||
//! # }
|
||||
//! ```
|
||||
|
|
Loading…
Reference in New Issue