mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-30 06:43:20 +03:00
Rollup merge of #134655 - GrigorenkoPV:hash_extract_if, r=cuviper
Stabilize `hash_extract_if` FCP complete: https://github.com/rust-lang/rust/issues/59618#issuecomment-2674880530 Tracking issue: #59618 Closes #59618
This commit is contained in:
@@ -656,7 +656,6 @@ pub fn drain(&mut self) -> Drain<'_, K, V> {
|
||||
/// Splitting a map into even and odd keys, reusing the original map:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(hash_extract_if)]
|
||||
/// use std::collections::HashMap;
|
||||
///
|
||||
/// let mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();
|
||||
@@ -672,7 +671,7 @@ pub fn drain(&mut self) -> Drain<'_, K, V> {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[rustc_lint_query_instability]
|
||||
#[unstable(feature = "hash_extract_if", issue = "59618")]
|
||||
#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
|
||||
where
|
||||
F: FnMut(&K, &mut V) -> bool,
|
||||
@@ -1722,8 +1721,6 @@ pub(super) fn iter(&self) -> Iter<'_, K, V> {
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(hash_extract_if)]
|
||||
///
|
||||
/// use std::collections::HashMap;
|
||||
///
|
||||
/// let mut map = HashMap::from([
|
||||
@@ -1731,7 +1728,7 @@ pub(super) fn iter(&self) -> Iter<'_, K, V> {
|
||||
/// ]);
|
||||
/// let iter = map.extract_if(|_k, v| *v % 2 == 0);
|
||||
/// ```
|
||||
#[unstable(feature = "hash_extract_if", issue = "59618")]
|
||||
#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[must_use = "iterators are lazy and do nothing unless consumed"]
|
||||
pub struct ExtractIf<'a, K, V, F>
|
||||
where
|
||||
@@ -2746,7 +2743,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "hash_extract_if", issue = "59618")]
|
||||
#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl<K, V, F> Iterator for ExtractIf<'_, K, V, F>
|
||||
where
|
||||
F: FnMut(&K, &mut V) -> bool,
|
||||
@@ -2763,10 +2760,10 @@ fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "hash_extract_if", issue = "59618")]
|
||||
#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl<K, V, F> FusedIterator for ExtractIf<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool {}
|
||||
|
||||
#[unstable(feature = "hash_extract_if", issue = "59618")]
|
||||
#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl<'a, K, V, F> fmt::Debug for ExtractIf<'a, K, V, F>
|
||||
where
|
||||
F: FnMut(&K, &mut V) -> bool,
|
||||
|
||||
@@ -293,7 +293,6 @@ pub fn drain(&mut self) -> Drain<'_, T> {
|
||||
/// Splitting a set into even and odd values, reusing the original set:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(hash_extract_if)]
|
||||
/// use std::collections::HashSet;
|
||||
///
|
||||
/// let mut set: HashSet<i32> = (0..8).collect();
|
||||
@@ -309,7 +308,7 @@ pub fn drain(&mut self) -> Drain<'_, T> {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[rustc_lint_query_instability]
|
||||
#[unstable(feature = "hash_extract_if", issue = "59618")]
|
||||
#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, T, F>
|
||||
where
|
||||
F: FnMut(&T) -> bool,
|
||||
@@ -1385,15 +1384,13 @@ pub struct Drain<'a, K: 'a> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(hash_extract_if)]
|
||||
///
|
||||
/// use std::collections::HashSet;
|
||||
///
|
||||
/// let mut a = HashSet::from([1, 2, 3]);
|
||||
///
|
||||
/// let mut extract_ifed = a.extract_if(|v| v % 2 == 0);
|
||||
/// ```
|
||||
#[unstable(feature = "hash_extract_if", issue = "59618")]
|
||||
#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub struct ExtractIf<'a, K, F>
|
||||
where
|
||||
F: FnMut(&K) -> bool,
|
||||
@@ -1676,7 +1673,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "hash_extract_if", issue = "59618")]
|
||||
#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl<K, F> Iterator for ExtractIf<'_, K, F>
|
||||
where
|
||||
F: FnMut(&K) -> bool,
|
||||
@@ -1693,10 +1690,10 @@ fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "hash_extract_if", issue = "59618")]
|
||||
#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl<K, F> FusedIterator for ExtractIf<'_, K, F> where F: FnMut(&K) -> bool {}
|
||||
|
||||
#[unstable(feature = "hash_extract_if", issue = "59618")]
|
||||
#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl<'a, K, F> fmt::Debug for ExtractIf<'a, K, F>
|
||||
where
|
||||
F: FnMut(&K) -> bool,
|
||||
|
||||
Reference in New Issue
Block a user