diff options
| author | bors <bors@rust-lang.org> | 2016-02-11 06:48:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-02-11 06:48:54 +0000 |
| commit | b9732ed1471689976fc32fa6757fd29c5a587f5d (patch) | |
| tree | 90c32e72558fedb9a7520b178583ed026b647258 /src/libstd | |
| parent | 1de70d33f7baf12978cfb3de861e61b2a5d6fca7 (diff) | |
| parent | ca7f550a6ecac44418f769e758955265da3e18fa (diff) | |
| download | rust-b9732ed1471689976fc32fa6757fd29c5a587f5d.tar.gz rust-b9732ed1471689976fc32fa6757fd29c5a587f5d.zip | |
Auto merge of #31357 - rthomas:hashers, r=alexcrichton
add a public hasher function for HashSet and HashMap
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 7 | ||||
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index f8efada9f6c..586fafc2b4a 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -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 diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index b5f47853afd..5c58cd9dfbf 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -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", |
