Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
///
/// If the returned `ExtractIf` is not exhausted, e.g. because it is dropped without iterating
/// or the iteration short-circuits, then the remaining elements will be retained.
/// Use [`retain`] with a negated predicate if you do not need the returned iterator.
/// Use `extract_if().for_each(drop)` if you do not need the returned iterator,
/// or [`retain`] with a negated predicate if you also do not need to restrict the range.
///
/// [`retain`]: BTreeMap::retain
///
Expand Down Expand Up @@ -1945,7 +1946,8 @@ impl<K, V> Default for Values<'_, K, V> {

/// An iterator produced by calling `extract_if` on BTreeMap.
#[stable(feature = "btree_extract_if", since = "1.91.0")]
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[must_use = "iterators are lazy and do nothing unless consumed; \
use `retain` or `extract_if().for_each(drop)` to remove and discard elements"]
pub struct ExtractIf<
'a,
K,
Expand Down
6 changes: 4 additions & 2 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,8 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
///
/// If the returned `ExtractIf` is not exhausted, e.g. because it is dropped without iterating
/// or the iteration short-circuits, then the remaining elements will be retained.
/// Use [`retain`] with a negated predicate if you do not need the returned iterator.
/// Use `extract_if().for_each(drop)` if you do not need the returned iterator,
/// or [`retain`] with a negated predicate if you also do not need to restrict the range.
///
/// [`retain`]: BTreeSet::retain
/// # Examples
Expand Down Expand Up @@ -1547,7 +1548,8 @@ impl<'a, T, A: Allocator + Clone> IntoIterator for &'a BTreeSet<T, A> {

/// An iterator produced by calling `extract_if` on BTreeSet.
#[stable(feature = "btree_extract_if", since = "1.91.0")]
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[must_use = "iterators are lazy and do nothing unless consumed; \
use `retain` or `extract_if().for_each(drop)` to remove and discard elements"]
pub struct ExtractIf<
'a,
T,
Expand Down
3 changes: 2 additions & 1 deletion library/alloc/src/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1943,7 +1943,8 @@ impl<'a, T, A: Allocator> CursorMut<'a, T, A> {

/// An iterator produced by calling `extract_if` on LinkedList.
#[stable(feature = "extract_if", since = "1.87.0")]
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[must_use = "iterators are lazy and do nothing unless consumed; \
use `extract_if().for_each(drop)` to remove and discard elements"]
pub struct ExtractIf<
'a,
T: 'a,
Expand Down
3 changes: 2 additions & 1 deletion library/alloc/src/collections/vec_deque/extract_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ use crate::alloc::{Allocator, Global};
/// let iter: ExtractIf<'_, _, _> = v.extract_if(.., |x| *x % 2 == 0);
/// ```
#[unstable(feature = "vec_deque_extract_if", issue = "147750")]
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[must_use = "iterators are lazy and do nothing unless consumed; \
use `retain_mut` or `extract_if().for_each(drop)` to remove and discard elements"]
pub struct ExtractIf<
'a,
T,
Expand Down
3 changes: 2 additions & 1 deletion library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
///
/// If the returned `ExtractIf` is not exhausted, e.g. because it is dropped without iterating
/// or the iteration short-circuits, then the remaining elements will be retained.
/// Use [`retain_mut`] with a negated predicate if you do not need the returned iterator.
/// Use `extract_if().for_each(drop)` if you do not need the returned iterator,
/// or [`retain_mut`] with a negated predicate if you also do not need to restrict the range.
///
/// [`retain_mut`]: VecDeque::retain_mut
///
Expand Down
3 changes: 2 additions & 1 deletion library/alloc/src/vec/extract_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use crate::alloc::{Allocator, Global};
/// let iter: std::vec::ExtractIf<'_, _, _> = v.extract_if(.., |x| *x % 2 == 0);
/// ```
#[stable(feature = "extract_if", since = "1.87.0")]
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[must_use = "iterators are lazy and do nothing unless consumed; \
use `retain_mut` or `extract_if().for_each(drop)` to remove and discard elements"]
pub struct ExtractIf<
'a,
T,
Expand Down
3 changes: 2 additions & 1 deletion library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3933,7 +3933,8 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// If the returned `ExtractIf` is not exhausted, e.g. because it is dropped without iterating
/// or the iteration short-circuits, then the remaining elements will be retained.
/// Use [`retain_mut`] with a negated predicate if you do not need the returned iterator.
/// Use `extract_if().for_each(drop)` if you do not need the returned iterator,
/// or [`retain_mut`] with a negated predicate if you also do not need to restrict the range.
///
/// [`retain_mut`]: Vec::retain_mut
///
Expand Down
3 changes: 2 additions & 1 deletion library/std/src/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,8 @@ impl<'a, K, V> Drain<'a, K, V> {
/// let iter = map.extract_if(|_k, v| *v % 2 == 0);
/// ```
#[stable(feature = "hash_extract_if", since = "1.88.0")]
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[must_use = "iterators are lazy and do nothing unless consumed; \
use `retain` to remove and discard elements"]
pub struct ExtractIf<'a, K, V, F> {
base: base::ExtractIf<'a, K, V, F>,
}
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,8 @@ pub struct Drain<'a, K: 'a> {
/// let mut extract_ifed = a.extract_if(|v| v % 2 == 0);
/// ```
#[stable(feature = "hash_extract_if", since = "1.88.0")]
#[must_use = "iterators are lazy and do nothing unless consumed; \
use `retain` to remove and discard elements"]
pub struct ExtractIf<'a, K, F> {
base: base::ExtractIf<'a, K, F>,
}
Expand Down
Loading