Examples use ?, not try!, not unwrap

To conform to Rust API guidelines examples should Examples use ?, not
try!, not unwrap (C-QUESTION-MARK).

Label the examples as `# Examples`.
Replace one `unwrap()` with `expect()` .  The others don't technically
conform to the guidelines but are warranted.
This commit is contained in:
Jamil Lambert, PhD 2024-11-28 22:20:57 +00:00
parent cefcce5bbf
commit 91268bba67
No known key found for this signature in database
GPG Key ID: 54DC29234AB5D2C0
1 changed files with 2 additions and 2 deletions

View File

@ -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);
//! # }
//! ```