Skip to content

Commit 1512e44

Browse files
authored
Rollup merge of rust-lang#43905 - partim:master, r=steveklabnik
Document that `std::hash::Hasher::finish()` does not reset the hasher. Clarifies the fact that `finish()` doesn’t in fact end or reset the hasher. This was surprising to me … Follows up on and fixes rust-lang#43763
2 parents a4387d5 + 02aaa11 commit 1512e44

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/libcore/hash/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,12 @@ pub trait Hash {
240240
/// [`write_u8`]: #method.write_u8
241241
#[stable(feature = "rust1", since = "1.0.0")]
242242
pub trait Hasher {
243-
/// Completes a round of hashing, producing the output hash generated.
243+
/// Returns the hash value for the values written so far.
244+
///
245+
/// Despite its name, the method does not reset the hasher’s internal
246+
/// state. Additional [`write`]s will continue from the current value.
247+
/// If you need to start a fresh hash value, you will have to create
248+
/// a new hasher.
244249
///
245250
/// # Examples
246251
///
@@ -253,6 +258,8 @@ pub trait Hasher {
253258
///
254259
/// println!("Hash is {:x}!", hasher.finish());
255260
/// ```
261+
///
262+
/// ['write']: #tymethod.write
256263
#[stable(feature = "rust1", since = "1.0.0")]
257264
fn finish(&self) -> u64;
258265

0 commit comments

Comments
 (0)