diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-08-17 10:44:08 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-17 10:44:08 -0400 |
| commit | 1512e44c17cdc03adb3a8d87a8a06df2e598069c (patch) | |
| tree | edd8bf069b8b2f5fbc67f3950a9af43ab473b4ad /src/libcore | |
| parent | a4387d54dca2160544fd0775c52ad942794e4f5f (diff) | |
| parent | 02aaa1180eca1c1a5979eb5b106ed1befba8a42e (diff) | |
| download | rust-1512e44c17cdc03adb3a8d87a8a06df2e598069c.tar.gz rust-1512e44c17cdc03adb3a8d87a8a06df2e598069c.zip | |
Rollup merge of #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 #43763
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/hash/mod.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index 2000ba91460..a8b84203d6a 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -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 /// @@ -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; |
