Skip to content

Commit ae20815

Browse files
authored
Unrolled build for #141924
Rollup merge of #141924 - rs-sac:extr-doc, r=jhpratt Lightly tweak docs for BTree{Map,Set}::extract_if - Move explanations into comments to match style - Explain the second examples - Make variable names match the data structure Related #70530
2 parents df8102f + a20cf47 commit ae20815

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

library/alloc/src/collections/btree/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,18 +1416,18 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
14161416
///
14171417
/// # Examples
14181418
///
1419-
/// Splitting a map into even and odd keys, reusing the original map:
1420-
///
14211419
/// ```
14221420
/// #![feature(btree_extract_if)]
14231421
/// use std::collections::BTreeMap;
14241422
///
1423+
/// // Splitting a map into even and odd keys, reusing the original map:
14251424
/// let mut map: BTreeMap<i32, i32> = (0..8).map(|x| (x, x)).collect();
14261425
/// let evens: BTreeMap<_, _> = map.extract_if(.., |k, _v| k % 2 == 0).collect();
14271426
/// let odds = map;
14281427
/// assert_eq!(evens.keys().copied().collect::<Vec<_>>(), [0, 2, 4, 6]);
14291428
/// assert_eq!(odds.keys().copied().collect::<Vec<_>>(), [1, 3, 5, 7]);
14301429
///
1430+
/// // Splitting a map into low and high halves, reusing the original map:
14311431
/// let mut map: BTreeMap<i32, i32> = (0..8).map(|x| (x, x)).collect();
14321432
/// let low: BTreeMap<_, _> = map.extract_if(0..4, |_k, _v| true).collect();
14331433
/// let high = map;

library/alloc/src/collections/btree/set.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,21 +1201,21 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
12011201
/// [`retain`]: BTreeSet::retain
12021202
/// # Examples
12031203
///
1204-
/// Splitting a set into even and odd values, reusing the original set:
1205-
///
12061204
/// ```
12071205
/// #![feature(btree_extract_if)]
12081206
/// use std::collections::BTreeSet;
12091207
///
1208+
/// // Splitting a set into even and odd values, reusing the original set:
12101209
/// let mut set: BTreeSet<i32> = (0..8).collect();
12111210
/// let evens: BTreeSet<_> = set.extract_if(.., |v| v % 2 == 0).collect();
12121211
/// let odds = set;
12131212
/// assert_eq!(evens.into_iter().collect::<Vec<_>>(), vec![0, 2, 4, 6]);
12141213
/// assert_eq!(odds.into_iter().collect::<Vec<_>>(), vec![1, 3, 5, 7]);
12151214
///
1216-
/// let mut map: BTreeSet<i32> = (0..8).collect();
1217-
/// let low: BTreeSet<_> = map.extract_if(0..4, |_v| true).collect();
1218-
/// let high = map;
1215+
/// // Splitting a set into low and high halves, reusing the original set:
1216+
/// let mut set: BTreeSet<i32> = (0..8).collect();
1217+
/// let low: BTreeSet<_> = set.extract_if(0..4, |_v| true).collect();
1218+
/// let high = set;
12191219
/// assert_eq!(low.into_iter().collect::<Vec<_>>(), [0, 1, 2, 3]);
12201220
/// assert_eq!(high.into_iter().collect::<Vec<_>>(), [4, 5, 6, 7]);
12211221
/// ```

0 commit comments

Comments
 (0)