about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-10-27 08:45:30 +0900
committerGitHub <noreply@github.com>2020-10-27 08:45:30 +0900
commit4236d27c9bb0af5cbdfaaa840b211827c65fb1ee (patch)
treef59af68727324057f7cf49b2b9fafface6d64b65
parent7824d9abbd06b212a45d79bf2dea6d24b3509eb9 (diff)
parent59f108885ed38c7f7049a1830b7c50205989cb17 (diff)
downloadrust-4236d27c9bb0af5cbdfaaa840b211827c65fb1ee.tar.gz
rust-4236d27c9bb0af5cbdfaaa840b211827c65fb1ee.zip
Rollup merge of #78412 - camelid:cleanup-hash-docs, r=jonas-schievink
Improve formatting of hash collections docs
-rw-r--r--library/std/src/collections/hash/map.rs7
-rw-r--r--library/std/src/collections/hash/set.rs4
2 files changed, 6 insertions, 5 deletions
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs
index 114707b639b..d1244c2ca53 100644
--- a/library/std/src/collections/hash/map.rs
+++ b/library/std/src/collections/hash/map.rs
@@ -606,7 +606,7 @@ where
     }
 
     /// Tries to reserve capacity for at least `additional` more elements to be inserted
-    /// in the given `HashMap<K,V>`. The collection may reserve more space to avoid
+    /// in the given `HashMap<K, V>`. The collection may reserve more space to avoid
     /// frequent reallocations.
     ///
     /// # Errors
@@ -619,6 +619,7 @@ where
     /// ```
     /// #![feature(try_reserve)]
     /// use std::collections::HashMap;
+    ///
     /// let mut map: HashMap<&str, isize> = HashMap::new();
     /// map.try_reserve(10).expect("why is the test harness OOMing on 10 bytes?");
     /// ```
@@ -898,14 +899,14 @@ where
 
     /// Retains only the elements specified by the predicate.
     ///
-    /// In other words, remove all pairs `(k, v)` such that `f(&k,&mut v)` returns `false`.
+    /// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`.
     ///
     /// # Examples
     ///
     /// ```
     /// use std::collections::HashMap;
     ///
-    /// let mut map: HashMap<i32, i32> = (0..8).map(|x|(x, x*10)).collect();
+    /// let mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();
     /// map.retain(|&k, _| k % 2 == 0);
     /// assert_eq!(map.len(), 4);
     /// ```
diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs
index a0c39852ad5..3299fd12e02 100644
--- a/library/std/src/collections/hash/set.rs
+++ b/library/std/src/collections/hash/set.rs
@@ -412,7 +412,7 @@ where
     }
 
     /// Tries to reserve capacity for at least `additional` more elements to be inserted
-    /// in the given `HashSet<K,V>`. The collection may reserve more space to avoid
+    /// in the given `HashSet<K, V>`. The collection may reserve more space to avoid
     /// frequent reallocations.
     ///
     /// # Errors
@@ -918,7 +918,7 @@ where
     /// ```
     /// use std::collections::HashSet;
     ///
-    /// let xs = [1,2,3,4,5,6];
+    /// let xs = [1, 2, 3, 4, 5, 6];
     /// let mut set: HashSet<i32> = xs.iter().cloned().collect();
     /// set.retain(|&k| k % 2 == 0);
     /// assert_eq!(set.len(), 3);