Add a public hasher function for HashSet and HashMap

This commit is contained in:
Ryan Thomas
2016-02-02 14:29:48 +11:00
parent b94cd7a5bd
commit ca7f550a6e
2 changed files with 14 additions and 0 deletions
+7
View File
@@ -642,6 +642,13 @@ pub fn with_capacity_and_hash_state(capacity: usize, hash_state: 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
+7
View File
@@ -193,6 +193,13 @@ pub fn with_capacity_and_hasher(capacity: usize, hasher: 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",