Skip to content

Commit 4236d27

Browse files
authored
Rollup merge of #78412 - camelid:cleanup-hash-docs, r=jonas-schievink
Improve formatting of hash collections docs
2 parents 7824d9a + 59f1088 commit 4236d27

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

library/std/src/collections/hash/map.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ where
606606
}
607607

608608
/// Tries to reserve capacity for at least `additional` more elements to be inserted
609-
/// in the given `HashMap<K,V>`. The collection may reserve more space to avoid
609+
/// in the given `HashMap<K, V>`. The collection may reserve more space to avoid
610610
/// frequent reallocations.
611611
///
612612
/// # Errors
@@ -619,6 +619,7 @@ where
619619
/// ```
620620
/// #![feature(try_reserve)]
621621
/// use std::collections::HashMap;
622+
///
622623
/// let mut map: HashMap<&str, isize> = HashMap::new();
623624
/// map.try_reserve(10).expect("why is the test harness OOMing on 10 bytes?");
624625
/// ```
@@ -898,14 +899,14 @@ where
898899

899900
/// Retains only the elements specified by the predicate.
900901
///
901-
/// In other words, remove all pairs `(k, v)` such that `f(&k,&mut v)` returns `false`.
902+
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`.
902903
///
903904
/// # Examples
904905
///
905906
/// ```
906907
/// use std::collections::HashMap;
907908
///
908-
/// let mut map: HashMap<i32, i32> = (0..8).map(|x|(x, x*10)).collect();
909+
/// let mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();
909910
/// map.retain(|&k, _| k % 2 == 0);
910911
/// assert_eq!(map.len(), 4);
911912
/// ```

library/std/src/collections/hash/set.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ where
412412
}
413413

414414
/// Tries to reserve capacity for at least `additional` more elements to be inserted
415-
/// in the given `HashSet<K,V>`. The collection may reserve more space to avoid
415+
/// in the given `HashSet<K, V>`. The collection may reserve more space to avoid
416416
/// frequent reallocations.
417417
///
418418
/// # Errors
@@ -918,7 +918,7 @@ where
918918
/// ```
919919
/// use std::collections::HashSet;
920920
///
921-
/// let xs = [1,2,3,4,5,6];
921+
/// let xs = [1, 2, 3, 4, 5, 6];
922922
/// let mut set: HashSet<i32> = xs.iter().cloned().collect();
923923
/// set.retain(|&k| k % 2 == 0);
924924
/// assert_eq!(set.len(), 3);

0 commit comments

Comments
 (0)