Skip to content

Commit 02aaa11

Browse files
committed
Document that std::hash::Hasher::finish() does not reset the hasher.
1 parent 85eadf8 commit 02aaa11

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/libcore/hash/mod.rs

+8-1
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)