Skip to content

Commit 747abb8

Browse files
Rollup merge of #81434 - ssomers:btree_drain_filter_doc_update, r=dtolnay
BTree: fix documentation of unstable public members As rightfully requested in #62924 & #70530. r? `@Mark-Simulacrum`
2 parents 7acf9ec + f0b8166 commit 747abb8

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

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

+17-15
Original file line numberDiff line numberDiff line change
@@ -1151,21 +1151,23 @@ impl<K, V> BTreeMap<K, V> {
11511151
right
11521152
}
11531153

1154-
/// Creates an iterator which uses a closure to determine if an element should be removed.
1155-
///
1156-
/// If the closure returns true, the element is removed from the map and yielded.
1157-
/// If the closure returns false, or panics, the element remains in the map and will not be
1158-
/// yielded.
1159-
///
1160-
/// Note that `drain_filter` lets you mutate every value in the filter closure, regardless of
1161-
/// whether you choose to keep or remove it.
1162-
///
1163-
/// If the iterator is only partially consumed or not consumed at all, each of the remaining
1164-
/// elements will still be subjected to the closure and removed and dropped if it returns true.
1165-
///
1166-
/// It is unspecified how many more elements will be subjected to the closure
1167-
/// if a panic occurs in the closure, or a panic occurs while dropping an element,
1168-
/// or if the `DrainFilter` value is leaked.
1154+
/// Creates an iterator that visits all elements (key-value pairs) in
1155+
/// ascending key order and uses a closure to determine if an element should
1156+
/// be removed. If the closure returns `true`, the element is removed from
1157+
/// the map and yielded. If the closure returns `false`, or panics, the
1158+
/// element remains in the map and will not be yielded.
1159+
///
1160+
/// The iterator also lets you mutate the value of each element in the
1161+
/// closure, regardless of whether you choose to keep or remove it.
1162+
///
1163+
/// If the iterator is only partially consumed or not consumed at all, each
1164+
/// of the remaining elements is still subjected to the closure, which may
1165+
/// change its value and, by returning `true`, have the element removed and
1166+
/// dropped.
1167+
///
1168+
/// It is unspecified how many more elements will be subjected to the
1169+
/// closure if a panic occurs in the closure, or a panic occurs while
1170+
/// dropping an element, or if the `DrainFilter` value is leaked.
11691171
///
11701172
/// # Examples
11711173
///

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ impl<T> BTreeSet<T> {
679679
/// use std::collections::BTreeSet;
680680
///
681681
/// let mut map = BTreeSet::new();
682-
/// assert_eq!(map.first(), None);
682+
/// assert_eq!(map.last(), None);
683683
/// map.insert(1);
684684
/// assert_eq!(map.last(), Some(&1));
685685
/// map.insert(2);

0 commit comments

Comments
 (0)