stabilize extract_if

This commit is contained in:
bendn 2025-02-16 12:38:11 +07:00
parent 1805b33483
commit c39f33baae
No known key found for this signature in database
GPG Key ID: 0D9D3A2A3B2A93D6
11 changed files with 9 additions and 22 deletions

View File

@ -15,7 +15,6 @@
#![feature(box_into_inner)] #![feature(box_into_inner)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(error_reporter)] #![feature(error_reporter)]
#![feature(extract_if)]
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(negative_impls)] #![feature(negative_impls)]

View File

@ -27,7 +27,6 @@
#![feature(array_windows)] #![feature(array_windows)]
#![feature(assert_matches)] #![feature(assert_matches)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(extract_if)]
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(iter_order_by)] #![feature(iter_order_by)]
#![feature(let_chains)] #![feature(let_chains)]

View File

@ -5,7 +5,6 @@
#![feature(coroutines)] #![feature(coroutines)]
#![feature(decl_macro)] #![feature(decl_macro)]
#![feature(error_iter)] #![feature(error_iter)]
#![feature(extract_if)]
#![feature(file_buffered)] #![feature(file_buffered)]
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(iter_from_coroutine)] #![feature(iter_from_coroutine)]

View File

@ -45,7 +45,6 @@
#![feature(decl_macro)] #![feature(decl_macro)]
#![feature(discriminant_kind)] #![feature(discriminant_kind)]
#![feature(extern_types)] #![feature(extern_types)]
#![feature(extract_if)]
#![feature(file_buffered)] #![feature(file_buffered)]
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(intra_doc_pointers)] #![feature(intra_doc_pointers)]

View File

@ -15,7 +15,6 @@
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(assert_matches)] #![feature(assert_matches)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(extract_if)]
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(iter_intersperse)] #![feature(iter_intersperse)]
#![feature(let_chains)] #![feature(let_chains)]

View File

@ -20,7 +20,6 @@
#![feature(associated_type_defaults)] #![feature(associated_type_defaults)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(cfg_version)] #![feature(cfg_version)]
#![feature(extract_if)]
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(iter_intersperse)] #![feature(iter_intersperse)]
#![feature(iterator_try_reduce)] #![feature(iterator_try_reduce)]

View File

@ -1140,7 +1140,6 @@ impl<T, A: Allocator> LinkedList<T, A> {
/// Splitting a list into evens and odds, reusing the original list: /// Splitting a list into evens and odds, reusing the original list:
/// ///
/// ``` /// ```
/// #![feature(extract_if)]
/// use std::collections::LinkedList; /// use std::collections::LinkedList;
/// ///
/// let mut numbers: LinkedList<u32> = LinkedList::new(); /// let mut numbers: LinkedList<u32> = LinkedList::new();
@ -1152,7 +1151,7 @@ impl<T, A: Allocator> LinkedList<T, A> {
/// assert_eq!(evens.into_iter().collect::<Vec<_>>(), vec![2, 4, 6, 8, 14]); /// assert_eq!(evens.into_iter().collect::<Vec<_>>(), vec![2, 4, 6, 8, 14]);
/// assert_eq!(odds.into_iter().collect::<Vec<_>>(), vec![1, 3, 5, 9, 11, 13, 15]); /// assert_eq!(odds.into_iter().collect::<Vec<_>>(), vec![1, 3, 5, 9, 11, 13, 15]);
/// ``` /// ```
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
pub fn extract_if<F>(&mut self, filter: F) -> ExtractIf<'_, T, F, A> pub fn extract_if<F>(&mut self, filter: F) -> ExtractIf<'_, T, F, A>
where where
F: FnMut(&mut T) -> bool, F: FnMut(&mut T) -> bool,
@ -1932,7 +1931,7 @@ impl<'a, T, A: Allocator> CursorMut<'a, T, A> {
} }
/// An iterator produced by calling `extract_if` on LinkedList. /// An iterator produced by calling `extract_if` on LinkedList.
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
#[must_use = "iterators are lazy and do nothing unless consumed"] #[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct ExtractIf< pub struct ExtractIf<
'a, 'a,
@ -1947,7 +1946,7 @@ pub struct ExtractIf<
old_len: usize, old_len: usize,
} }
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
impl<T, F, A: Allocator> Iterator for ExtractIf<'_, T, F, A> impl<T, F, A: Allocator> Iterator for ExtractIf<'_, T, F, A>
where where
F: FnMut(&mut T) -> bool, F: FnMut(&mut T) -> bool,
@ -1976,7 +1975,7 @@ where
} }
} }
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
impl<T: fmt::Debug, F> fmt::Debug for ExtractIf<'_, T, F> { impl<T: fmt::Debug, F> fmt::Debug for ExtractIf<'_, T, F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("ExtractIf").field(&self.list).finish() f.debug_tuple("ExtractIf").field(&self.list).finish()

View File

@ -12,12 +12,10 @@ use crate::alloc::{Allocator, Global};
/// # Example /// # Example
/// ///
/// ``` /// ```
/// #![feature(extract_if)]
///
/// let mut v = vec![0, 1, 2]; /// let mut v = vec![0, 1, 2];
/// let iter: std::vec::ExtractIf<'_, _, _> = v.extract_if(.., |x| *x % 2 == 0); /// let iter: std::vec::ExtractIf<'_, _, _> = v.extract_if(.., |x| *x % 2 == 0);
/// ``` /// ```
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
#[derive(Debug)] #[derive(Debug)]
#[must_use = "iterators are lazy and do nothing unless consumed"] #[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct ExtractIf< pub struct ExtractIf<
@ -59,7 +57,7 @@ impl<'a, T, F, A: Allocator> ExtractIf<'a, T, F, A> {
} }
} }
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
impl<T, F, A: Allocator> Iterator for ExtractIf<'_, T, F, A> impl<T, F, A: Allocator> Iterator for ExtractIf<'_, T, F, A>
where where
F: FnMut(&mut T) -> bool, F: FnMut(&mut T) -> bool,
@ -95,7 +93,7 @@ where
} }
} }
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
impl<T, F, A: Allocator> Drop for ExtractIf<'_, T, F, A> { impl<T, F, A: Allocator> Drop for ExtractIf<'_, T, F, A> {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {

View File

@ -66,7 +66,7 @@ use core::ptr::{self, NonNull};
use core::slice::{self, SliceIndex}; use core::slice::{self, SliceIndex};
use core::{fmt, intrinsics}; use core::{fmt, intrinsics};
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
pub use self::extract_if::ExtractIf; pub use self::extract_if::ExtractIf;
use crate::alloc::{Allocator, Global}; use crate::alloc::{Allocator, Global};
use crate::borrow::{Cow, ToOwned}; use crate::borrow::{Cow, ToOwned};
@ -3684,7 +3684,6 @@ impl<T, A: Allocator> Vec<T, A> {
/// Splitting an array into evens and odds, reusing the original allocation: /// Splitting an array into evens and odds, reusing the original allocation:
/// ///
/// ``` /// ```
/// #![feature(extract_if)]
/// let mut numbers = vec![1, 2, 3, 4, 5, 6, 8, 9, 11, 13, 14, 15]; /// let mut numbers = vec![1, 2, 3, 4, 5, 6, 8, 9, 11, 13, 14, 15];
/// ///
/// let evens = numbers.extract_if(.., |x| *x % 2 == 0).collect::<Vec<_>>(); /// let evens = numbers.extract_if(.., |x| *x % 2 == 0).collect::<Vec<_>>();
@ -3697,13 +3696,12 @@ impl<T, A: Allocator> Vec<T, A> {
/// Using the range argument to only process a part of the vector: /// Using the range argument to only process a part of the vector:
/// ///
/// ``` /// ```
/// #![feature(extract_if)]
/// let mut items = vec![0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 2]; /// let mut items = vec![0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 2];
/// let ones = items.extract_if(7.., |x| *x == 1).collect::<Vec<_>>(); /// let ones = items.extract_if(7.., |x| *x == 1).collect::<Vec<_>>();
/// assert_eq!(items, vec![0, 0, 0, 0, 0, 0, 0, 2, 2, 2]); /// assert_eq!(items, vec![0, 0, 0, 0, 0, 0, 0, 2, 2, 2]);
/// assert_eq!(ones.len(), 3); /// assert_eq!(ones.len(), 3);
/// ``` /// ```
#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")]
pub fn extract_if<F, R>(&mut self, range: R, filter: F) -> ExtractIf<'_, T, F, A> pub fn extract_if<F, R>(&mut self, range: R, filter: F) -> ExtractIf<'_, T, F, A>
where where
F: FnMut(&mut T) -> bool, F: FnMut(&mut T) -> bool,

View File

@ -7,7 +7,6 @@
#![feature(cow_is_borrowed)] #![feature(cow_is_borrowed)]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(downcast_unchecked)] #![feature(downcast_unchecked)]
#![feature(extract_if)]
#![feature(exact_size_is_empty)] #![feature(exact_size_is_empty)]
#![feature(hashmap_internals)] #![feature(hashmap_internals)]
#![feature(linked_list_cursors)] #![feature(linked_list_cursors)]

View File

@ -16,7 +16,6 @@
#![feature(unqualified_local_imports)] #![feature(unqualified_local_imports)]
#![feature(derive_coerce_pointee)] #![feature(derive_coerce_pointee)]
#![feature(arbitrary_self_types)] #![feature(arbitrary_self_types)]
#![feature(extract_if)]
// Configure clippy and other lints // Configure clippy and other lints
#![allow( #![allow(
clippy::collapsible_else_if, clippy::collapsible_else_if,