@@ -2511,29 +2511,24 @@ impl<T, A: Allocator> Vec<T, A> {
2511
2511
}
2512
2512
}
2513
2513
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
2515
2515
/// 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) .
2517
2517
///
2518
2518
/// # Examples
2519
2519
///
2520
2520
/// ```
2521
- /// #![feature(vec_pop_if)]
2522
- ///
2523
2521
/// let mut vec = vec![1, 2, 3, 4];
2524
2522
/// let pred = |x: &mut i32| *x % 2 == 0;
2525
2523
///
2526
2524
/// assert_eq!(vec.pop_if(pred), Some(4));
2527
2525
/// assert_eq!(vec, [1, 2, 3]);
2528
2526
/// assert_eq!(vec.pop_if(pred), None);
2529
2527
/// ```
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 > {
2535
2530
let last = self . last_mut ( ) ?;
2536
- if f ( last) { self . pop ( ) } else { None }
2531
+ if predicate ( last) { self . pop ( ) } else { None }
2537
2532
}
2538
2533
2539
2534
/// Moves all the elements of `other` into `self`, leaving `other` empty.
0 commit comments