@@ -54,22 +54,35 @@ pub use crate::murmur3::Hasher as Murmur3Hasher;
54
54
mod fnv;
55
55
mod murmur3;
56
56
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 .
58
58
///
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`].
63
61
///
64
62
/// # Contract
65
63
///
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
67
65
/// 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
+ /// ```
68
82
pub 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.
72
84
///
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.
74
87
fn finish32 ( & self ) -> u32 ;
75
88
}
0 commit comments