@@ -268,10 +268,29 @@ pub use macros::Hash;
268
268
/// instance (with [`write`] and [`write_u8`] etc.). Most of the time, `Hasher`
269
269
/// instances are used in conjunction with the [`Hash`] trait.
270
270
///
271
- /// This trait makes no assumptions about how the various `write_*` methods are
271
+ /// This trait provides no guarantees about how the various `write_*` methods are
272
272
/// defined and implementations of [`Hash`] should not assume that they work one
273
273
/// way or another. You cannot assume, for example, that a [`write_u32`] call is
274
- /// equivalent to four calls of [`write_u8`].
274
+ /// equivalent to four calls of [`write_u8`]. Nor can you assume that adjacent
275
+ /// `write` calls are merged, so it's possible, for example, that
276
+ /// ```
277
+ /// # fn foo(hasher: &mut impl std::hash::Hasher) {
278
+ /// hasher.write(&[1, 2]);
279
+ /// hasher.write(&[3, 4, 5, 6]);
280
+ /// # }
281
+ /// ```
282
+ /// and
283
+ /// ```
284
+ /// # fn foo(hasher: &mut impl std::hash::Hasher) {
285
+ /// hasher.write(&[1, 2, 3, 4]);
286
+ /// hasher.write(&[5, 6]);
287
+ /// # }
288
+ /// ```
289
+ /// end up producing different hashes.
290
+ ///
291
+ /// Thus to produce the same hash value, [`Hash`] implementations must ensure
292
+ /// for equivalent items that exactly the same sequence of calls is made -- the
293
+ /// same methods with the same parameters in the same order.
275
294
///
276
295
/// # Examples
277
296
///
0 commit comments