]> git.lizzy.rs Git - rust.git/commitdiff
Add doc example for HashSet::hasher.
authorCorey Farwell <coreyf@rwell.org>
Tue, 1 Aug 2017 11:41:06 +0000 (07:41 -0400)
committerCorey Farwell <coreyf@rwell.org>
Tue, 1 Aug 2017 23:51:00 +0000 (19:51 -0400)
src/libstd/collections/hash/set.rs

index d80df5f18b610ba3f6df437aba1ac522371aa7f1..040595bbb0426b364c4aadd1a9369b2073674c88 100644 (file)
@@ -215,6 +215,17 @@ pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashSet<T, S> {
     /// Returns a reference to the set's [`BuildHasher`].
     ///
     /// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use std::collections::HashSet;
+    /// use std::collections::hash_map::RandomState;
+    ///
+    /// let hasher = RandomState::new();
+    /// let set: HashSet<i32> = HashSet::with_hasher(hasher);
+    /// let hasher: &RandomState = set.hasher();
+    /// ```
     #[stable(feature = "hashmap_public_hasher", since = "1.9.0")]
     pub fn hasher(&self) -> &S {
         self.map.hasher()