Skip to content

Commit

Permalink
Rollup merge of #71677 - Mark-Simulacrum:hasher-docs, r=Amanieu
Browse files Browse the repository at this point in the history
Add explicit references to the BuildHasher trait

Fixes #71652
  • Loading branch information
Dylan-DPC authored May 16, 2020
2 parents 86f48c5 + cf5e4a7 commit 21d58a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ impl<K, V, S> HashMap<K, V, S> {
/// cause many collisions and very poor performance. Setting it
/// manually using this function can expose a DoS attack vector.
///
/// The `hash_builder` passed should implement the [`BuildHasher`] trait for
/// the HashMap to be useful, see its documentation for details.
///
/// # Examples
///
/// ```
Expand All @@ -261,6 +264,8 @@ impl<K, V, S> HashMap<K, V, S> {
/// let mut map = HashMap::with_hasher(s);
/// map.insert(1, 2);
/// ```
///
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
#[inline]
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
pub fn with_hasher(hash_builder: S) -> HashMap<K, V, S> {
Expand All @@ -278,6 +283,9 @@ impl<K, V, S> HashMap<K, V, S> {
/// cause many collisions and very poor performance. Setting it
/// manually using this function can expose a DoS attack vector.
///
/// The `hash_builder` passed should implement the [`BuildHasher`] trait for
/// the HashMap to be useful, see its documentation for details.
///
/// # Examples
///
/// ```
Expand All @@ -288,6 +296,8 @@ impl<K, V, S> HashMap<K, V, S> {
/// let mut map = HashMap::with_capacity_and_hasher(10, s);
/// map.insert(1, 2);
/// ```
///
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
#[inline]
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> HashMap<K, V, S> {
Expand Down
10 changes: 10 additions & 0 deletions src/libstd/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ impl<T, S> HashSet<T, S> {
/// cause many collisions and very poor performance. Setting it
/// manually using this function can expose a DoS attack vector.
///
/// The `hash_builder` passed should implement the [`BuildHasher`] trait for
/// the HashMap to be useful, see its documentation for details.
///
/// # Examples
///
/// ```
Expand All @@ -283,6 +286,8 @@ impl<T, S> HashSet<T, S> {
/// let mut set = HashSet::with_hasher(s);
/// set.insert(2);
/// ```
///
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
#[inline]
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
pub fn with_hasher(hasher: S) -> HashSet<T, S> {
Expand All @@ -300,6 +305,9 @@ impl<T, S> HashSet<T, S> {
/// cause many collisions and very poor performance. Setting it
/// manually using this function can expose a DoS attack vector.
///
/// The `hash_builder` passed should implement the [`BuildHasher`] trait for
/// the HashMap to be useful, see its documentation for details.
///
/// # Examples
///
/// ```
Expand All @@ -310,6 +318,8 @@ impl<T, S> HashSet<T, S> {
/// let mut set = HashSet::with_capacity_and_hasher(10, s);
/// set.insert(1);
/// ```
///
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
#[inline]
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashSet<T, S> {
Expand Down

0 comments on commit 21d58a1

Please sign in to comment.