Skip to content

Commit

Permalink
Rollup merge of #78412 - camelid:cleanup-hash-docs, r=jonas-schievink
Browse files Browse the repository at this point in the history
Improve formatting of hash collections docs
  • Loading branch information
JohnTitor committed Oct 26, 2020
2 parents 7824d9a + 59f1088 commit 4236d27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions library/std/src/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?");
/// ```
Expand Down Expand Up @@ -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);
/// ```
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4236d27

Please sign in to comment.