Auto merge of #31357 - rthomas:hashers, r=alexcrichton
add a public hasher function for HashSet and HashMap
This commit is contained in:
commit
b9732ed147
@ -645,6 +645,13 @@ impl<K, V, S> HashMap<K, V, S>
|
||||
HashMap::with_capacity_and_hasher(capacity, hash_state)
|
||||
}
|
||||
|
||||
/// Returns a reference to the map's hasher.
|
||||
#[unstable(feature = "hashmap_public_hasher", reason = "don't want to make insta-stable",
|
||||
issue = "31262")]
|
||||
pub fn hasher(&self) -> &S {
|
||||
&self.hash_builder
|
||||
}
|
||||
|
||||
/// Returns the number of elements the map can hold without reallocating.
|
||||
///
|
||||
/// This number is a lower bound; the `HashMap<K, V>` might be able to hold
|
||||
|
@ -193,6 +193,13 @@ impl<T, S> HashSet<T, S>
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a reference to the set's hasher.
|
||||
#[unstable(feature = "hashmap_public_hasher", reason = "don't want to make insta-stable",
|
||||
issue = "31262")]
|
||||
pub fn hasher(&self) -> &S {
|
||||
self.map.hasher()
|
||||
}
|
||||
|
||||
/// Deprecated, renamed to `with_hasher`
|
||||
#[inline]
|
||||
#[unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear",
|
||||
|
Loading…
Reference in New Issue
Block a user