Skip to content

Commit bc43e17

Browse files
committed
Add doc example to HashMap::hasher
1 parent a83c3e7 commit bc43e17

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

Lines changed: 11 additions & 0 deletions
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)