@@ -2511,9 +2511,9 @@ 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
///
@@ -2528,12 +2528,9 @@ impl<T, A: Allocator> Vec<T, A> {
2528
2528
/// assert_eq!(vec.pop_if(pred), None);
2529
2529
/// ```
2530
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
- {
2531
+ pub fn pop_if ( & mut self , predicate : impl FnOnce ( & mut T ) -> bool ) -> Option < T > {
2535
2532
let last = self . last_mut ( ) ?;
2536
- if f ( last) { self . pop ( ) } else { None }
2533
+ if predicate ( last) { self . pop ( ) } else { None }
2537
2534
}
2538
2535
2539
2536
/// Moves all the elements of `other` into `self`, leaving `other` empty.
@@ -2574,9 +2571,11 @@ impl<T, A: Allocator> Vec<T, A> {
2574
2571
self . len += count;
2575
2572
}
2576
2573
2577
- /// Removes the specified range from the vector in bulk, returning all
2578
- /// removed elements as an iterator. If the iterator is dropped before
2579
- /// being fully consumed, it drops the remaining removed elements.
2574
+ /// Removes the subslice indicated by the given range from the vector,
2575
+ /// returning a double-ended iterator over the removed subslice.
2576
+ ///
2577
+ /// If the iterator is dropped before being fully consumed,
2578
+ /// it drops the remaining removed elements.
2580
2579
///
2581
2580
/// The returned iterator keeps a mutable borrow on the vector to optimize
2582
2581
/// its implementation.
@@ -3016,10 +3015,9 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
3016
3015
/// Iterates over the slice `other`, clones each element, and then appends
3017
3016
/// it to this `Vec`. The `other` slice is traversed in-order.
3018
3017
///
3019
- /// Note that this function is same as [`extend`] except that it is
3020
- /// specialized to work with slices instead. If and when Rust gets
3021
- /// specialization this function will likely be deprecated (but still
3022
- /// available).
3018
+ /// Note that this function is the same as [`extend`],
3019
+ /// except that it also works with slice elements that are Clone but not Copy.
3020
+ /// If Rust gets specialization this function may be deprecated.
3023
3021
///
3024
3022
/// # Examples
3025
3023
///
0 commit comments