Skip to content

Commit cf5e4a7

Browse files
Add explicit references to the BuildHasher trait
1 parent e91aebc commit cf5e4a7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/libstd/collections/hash/map.rs

+10
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ impl<K, V, S> HashMap<K, V, S> {
251251
/// cause many collisions and very poor performance. Setting it
252252
/// manually using this function can expose a DoS attack vector.
253253
///
254+
/// The `hash_builder` passed should implement the [`BuildHasher`] trait for
255+
/// the HashMap to be useful, see its documentation for details.
256+
///
254257
/// # Examples
255258
///
256259
/// ```
@@ -261,6 +264,8 @@ impl<K, V, S> HashMap<K, V, S> {
261264
/// let mut map = HashMap::with_hasher(s);
262265
/// map.insert(1, 2);
263266
/// ```
267+
///
268+
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
264269
#[inline]
265270
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
266271
pub fn with_hasher(hash_builder: S) -> HashMap<K, V, S> {
@@ -278,6 +283,9 @@ impl<K, V, S> HashMap<K, V, S> {
278283
/// cause many collisions and very poor performance. Setting it
279284
/// manually using this function can expose a DoS attack vector.
280285
///
286+
/// The `hash_builder` passed should implement the [`BuildHasher`] trait for
287+
/// the HashMap to be useful, see its documentation for details.
288+
///
281289
/// # Examples
282290
///
283291
/// ```
@@ -288,6 +296,8 @@ impl<K, V, S> HashMap<K, V, S> {
288296
/// let mut map = HashMap::with_capacity_and_hasher(10, s);
289297
/// map.insert(1, 2);
290298
/// ```
299+
///
300+
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
291301
#[inline]
292302
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
293303
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> HashMap<K, V, S> {

src/libstd/collections/hash/set.rs

+10
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ impl<T, S> HashSet<T, S> {
273273
/// cause many collisions and very poor performance. Setting it
274274
/// manually using this function can expose a DoS attack vector.
275275
///
276+
/// The `hash_builder` passed should implement the [`BuildHasher`] trait for
277+
/// the HashMap to be useful, see its documentation for details.
278+
///
276279
/// # Examples
277280
///
278281
/// ```
@@ -283,6 +286,8 @@ impl<T, S> HashSet<T, S> {
283286
/// let mut set = HashSet::with_hasher(s);
284287
/// set.insert(2);
285288
/// ```
289+
///
290+
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
286291
#[inline]
287292
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
288293
pub fn with_hasher(hasher: S) -> HashSet<T, S> {
@@ -300,6 +305,9 @@ impl<T, S> HashSet<T, S> {
300305
/// cause many collisions and very poor performance. Setting it
301306
/// manually using this function can expose a DoS attack vector.
302307
///
308+
/// The `hash_builder` passed should implement the [`BuildHasher`] trait for
309+
/// the HashMap to be useful, see its documentation for details.
310+
///
303311
/// # Examples
304312
///
305313
/// ```
@@ -310,6 +318,8 @@ impl<T, S> HashSet<T, S> {
310318
/// let mut set = HashSet::with_capacity_and_hasher(10, s);
311319
/// set.insert(1);
312320
/// ```
321+
///
322+
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
313323
#[inline]
314324
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
315325
pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashSet<T, S> {

0 commit comments

Comments
 (0)