@@ -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.
0 commit comments