File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -153,9 +153,19 @@ mod sip;
153153/// Thankfully, you won't need to worry about upholding this property when
154154/// deriving both [`Eq`] and `Hash` with `#[derive(PartialEq, Eq, Hash)]`.
155155///
156+ /// ## Prefix collisions
157+ ///
158+ /// Implementations of `hash` should ensure that the data they
159+ /// pass to the `Hasher` are prefix-free. That is, different concatenations
160+ /// of the same data should not produce the same output.
161+ /// For example, the standard implementation of [`Hash` for `&str`][impl] passes an extra
162+ /// `0xFF` byte to the `Hasher` so that the values `("ab", "c")` and `("a",
163+ /// "bc")` hash differently.
164+ ///
156165/// [`HashMap`]: ../../std/collections/struct.HashMap.html
157166/// [`HashSet`]: ../../std/collections/struct.HashSet.html
158167/// [`hash`]: Hash::hash
168+ /// [impl]: ../../std/primitive.str.html#impl-Hash
159169#[ stable( feature = "rust1" , since = "1.0.0" ) ]
160170#[ rustc_diagnostic_item = "Hash" ]
161171pub trait Hash {
You can’t perform that action at this time.
0 commit comments