Skip to content

Commit f2feb83

Browse files
Rollup merge of rust-lang#44794 - napen123:master, r=frewsxcv
Add doc example to HashMap::hasher None
2 parents 8083877 + bc43e17 commit f2feb83

File tree

1 file changed

+11
-0
lines changed
  • src/libstd/collections/hash

1 file changed

+11
-0
lines changed

src/libstd/collections/hash/map.rs

+11
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,17 @@ impl<K, V, S> HashMap<K, V, S>
691691
/// Returns a reference to the map's [`BuildHasher`].
692692
///
693693
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
694+
///
695+
/// # Examples
696+
///
697+
/// ```
698+
/// use std::collections::HashMap;
699+
/// use std::collections::hash_map::RandomState;
700+
///
701+
/// let hasher = RandomState::new();
702+
/// let map: HashMap<isize, isize> = HashMap::with_hasher(hasher);
703+
/// let hasher: &RandomState = map.hasher();
704+
/// ```
694705
#[stable(feature = "hashmap_public_hasher", since = "1.9.0")]
695706
pub fn hasher(&self) -> &S {
696707
&self.hash_builder

0 commit comments

Comments
 (0)