@@ -54,22 +54,35 @@ pub use crate::murmur3::Hasher as Murmur3Hasher;
5454mod fnv;
5555mod murmur3;
5656
57- /// An extension of [core::hash::Hasher][0] for hashers which use 32 bits .
57+ /// An extension of [` core::hash::Hasher`] for 32-bit hashers .
5858///
59- /// For hashers which implement this trait, the standard `finish` method should just return a
60- /// zero-extended version of the result of `finish32`.
61- ///
62- /// [0]: https://doc.rust-lang.org/core/hash/trait.Hasher.html
59+ /// For hashers that implement this trait, the [`core::hash::Hasher::finish`] method should return a
60+ /// zero-extended version of the result from [`Hasher::finish32`].
6361///
6462/// # Contract
6563///
66- /// Implementers of this trait must *not* perform any 64-bit (or 128-bit) operation while computing
64+ /// Implementers of this trait must ** not* * perform any 64-bit (or 128-bit) operation while computing
6765/// the hash.
66+ ///
67+ /// # Examples
68+ ///
69+ /// ```
70+ /// use core::hash::{Hasher as _};
71+ /// use hash32::{FnvHasher, Hasher as _};
72+ ///
73+ /// let mut hasher: FnvHasher = Default::default();
74+ ///
75+ /// hasher.write_u32(1989);
76+ /// hasher.write_u8(11);
77+ /// hasher.write_u8(9);
78+ /// hasher.write(b"Huh?");
79+ ///
80+ /// println!("Hash is {:x}!", hasher.finish32());
81+ /// ```
6882pub trait Hasher : core:: hash:: Hasher {
69- /// The equivalent of [`core::hash::Hasher.finish`][0] for 32-bit hashers.
70- ///
71- /// This returns the hash directly; `finish` zero-extends it to 64 bits for compatibility.
83+ /// The equivalent of [`core::hash::Hasher::finish`] for 32-bit hashers.
7284 ///
73- /// [0]: https://doc.rust-lang.org/std/hash/trait.Hasher.html#tymethod.finish
85+ /// This returns the hash directly; [`core::hash::Hasher::finish`] zero-extends the `finish32`
86+ /// result to 64-bits for compatibility.
7487 fn finish32 ( & self ) -> u32 ;
7588}
0 commit comments