From 59f108885ed38c7f7049a1830b7c50205989cb17 Mon Sep 17 00:00:00 2001 From: Camelid Date: Mon, 26 Oct 2020 14:05:06 -0700 Subject: [PATCH] Improve formatting of hash collections docs --- library/std/src/collections/hash/map.rs | 7 ++++--- library/std/src/collections/hash/set.rs | 4 ++-- 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 114707b639bce..d1244c2ca538c 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`. The collection may reserve more space to avoid + /// in the given `HashMap`. 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 = (0..8).map(|x|(x, x*10)).collect(); + /// let mut map: HashMap = (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 a0c39852ad5d8..3299fd12e024e 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`. The collection may reserve more space to avoid + /// in the given `HashSet`. 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 = xs.iter().cloned().collect(); /// set.retain(|&k| k % 2 == 0); /// assert_eq!(set.len(), 3);