Skip to content

Commit 1fe4df6

Browse files
committed
Stabilize vec_pop_if
1 parent b2728d5 commit 1fe4df6

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

library/alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
#![feature(unicode_internals)]
154154
#![feature(unsize)]
155155
#![feature(unwrap_infallible)]
156-
#![feature(vec_pop_if)]
157156
// tidy-alphabetical-end
158157
//
159158
// Language features:

library/alloc/src/vec/mod.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -2511,29 +2511,24 @@ impl<T, A: Allocator> Vec<T, A> {
25112511
}
25122512
}
25132513

2514-
/// Removes and returns the last element in a vector if the predicate
2514+
/// Removes and returns the last element from a vector if the predicate
25152515
/// returns `true`, or [`None`] if the predicate returns false or the vector
2516-
/// is empty.
2516+
/// is empty (the predicate will not be called in that case).
25172517
///
25182518
/// # Examples
25192519
///
25202520
/// ```
2521-
/// #![feature(vec_pop_if)]
2522-
///
25232521
/// let mut vec = vec![1, 2, 3, 4];
25242522
/// let pred = |x: &mut i32| *x % 2 == 0;
25252523
///
25262524
/// assert_eq!(vec.pop_if(pred), Some(4));
25272525
/// assert_eq!(vec, [1, 2, 3]);
25282526
/// assert_eq!(vec.pop_if(pred), None);
25292527
/// ```
2530-
#[unstable(feature = "vec_pop_if", issue = "122741")]
2531-
pub fn pop_if<F>(&mut self, f: F) -> Option<T>
2532-
where
2533-
F: FnOnce(&mut T) -> bool,
2534-
{
2528+
#[stable(feature = "vec_pop_if", since = "CURRENT_RUSTC_VERSION")]
2529+
pub fn pop_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option<T> {
25352530
let last = self.last_mut()?;
2536-
if f(last) { self.pop() } else { None }
2531+
if predicate(last) { self.pop() } else { None }
25372532
}
25382533

25392534
/// Moves all the elements of `other` into `self`, leaving `other` empty.

library/alloc/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#![feature(local_waker)]
3838
#![feature(str_as_str)]
3939
#![feature(strict_provenance_lints)]
40-
#![feature(vec_pop_if)]
4140
#![feature(unique_rc_arc)]
4241
#![feature(macro_metavar_expr_concat)]
4342
#![allow(internal_features)]

0 commit comments

Comments
 (0)