File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -153,9 +153,19 @@ mod sip;
153
153
/// Thankfully, you won't need to worry about upholding this property when
154
154
/// deriving both [`Eq`] and `Hash` with `#[derive(PartialEq, Eq, Hash)]`.
155
155
///
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
+ ///
156
165
/// [`HashMap`]: ../../std/collections/struct.HashMap.html
157
166
/// [`HashSet`]: ../../std/collections/struct.HashSet.html
158
167
/// [`hash`]: Hash::hash
168
+ /// [impl]: ../../std/primitive.str.html#impl-Hash
159
169
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
160
170
#[ rustc_diagnostic_item = "Hash" ]
161
171
pub trait Hash {
You can’t perform that action at this time.
0 commit comments