Skip to content

Commit

Permalink
Rollup merge of rust-lang#43905 - partim:master, r=steveklabnik
Browse files Browse the repository at this point in the history
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
  • Loading branch information
frewsxcv authored Aug 17, 2017
2 parents a4387d5 + 02aaa11 commit 1512e44
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libcore/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,12 @@ pub trait Hash {
/// [`write_u8`]: #method.write_u8
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Hasher {
/// Completes a round of hashing, producing the output hash generated.
/// Returns the hash value for the values written so far.
///
/// Despite its name, the method does not reset the hasher’s internal
/// state. Additional [`write`]s will continue from the current value.
/// If you need to start a fresh hash value, you will have to create
/// a new hasher.
///
/// # Examples
///
Expand All @@ -253,6 +258,8 @@ pub trait Hasher {
///
/// println!("Hash is {:x}!", hasher.finish());
/// ```
///
/// ['write']: #tymethod.write
#[stable(feature = "rust1", since = "1.0.0")]
fn finish(&self) -> u64;

Expand Down

0 comments on commit 1512e44

Please sign in to comment.