Skip to content

Commit 2a23e6e

Browse files
author
lukaramu
committed
std::collections docs: Address issues that came up in PR #41286
* Bound: * Added another example using RangeArgument to illustrate how Bound maps to range endpoints. * Added a note to the existing example that says that it's better to use range syntax in most cases * Added missing /// line * binary_heap::PeakMut: s/Object representing/Structure wrapping * added collections/hash_set/struct.HashSet.html to linkchecker whitelist
1 parent 89ac865 commit 2a23e6e

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/libcollections/binary_heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ pub struct BinaryHeap<T> {
219219
data: Vec<T>,
220220
}
221221

222-
/// Object representing a mutable reference to the greatest item on a
222+
/// Structure wrapping a mutable reference to the greatest item on a
223223
/// `BinaryHeap`.
224224
///
225225
/// This `struct` is created by the [`peek_mut`] method on [`BinaryHeap`]. See

src/libcollections/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,25 @@ mod std {
135135
}
136136

137137
/// An endpoint of a range of keys.
138+
///
138139
/// # Examples
139140
///
141+
/// `Bound`s are range endpoints:
142+
///
143+
/// ```
144+
/// #![feature(collections_range)]
145+
///
146+
/// use std::collections::range::RangeArgument;
147+
/// use std::collections::Bound::*;
148+
///
149+
/// assert_eq!((..100).start(), Unbounded);
150+
/// assert_eq!((1..12).start(), Included(&1));
151+
/// assert_eq!((1..12).end(), Excluded(&12));
152+
/// ```
153+
///
154+
/// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
155+
/// Note that in most cases, it's better to use range syntax (`1..5`) instead.
156+
///
140157
/// ```
141158
/// use std::collections::BTreeMap;
142159
/// use std::collections::Bound::{Excluded, Included, Unbounded};
@@ -152,6 +169,8 @@ mod std {
152169
///
153170
/// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next());
154171
/// ```
172+
///
173+
/// [`BTreeMap::range`]: btree_map/struct.BTreeMap.html#method.range
155174
#[stable(feature = "collections_bound", since = "1.17.0")]
156175
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
157176
pub enum Bound<T> {

src/tools/linkchecker/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ fn check(cache: &mut Cache,
142142
if file.ends_with("btree_set/struct.BTreeSet.html") ||
143143
file.ends_with("collections/struct.BTreeSet.html") ||
144144
file.ends_with("collections/btree_map/struct.BTreeMap.html") ||
145-
file.ends_with("collections/hash_map/struct.HashMap.html") {
145+
file.ends_with("collections/hash_map/struct.HashMap.html") ||
146+
file.ends_with("collections/hash_set/struct.HashSet.html") {
146147
return None;
147148
}
148149

0 commit comments

Comments
 (0)