mod cow;
#[cfg(not(no_global_oom_handling))]
-pub(crate) use self::into_iter::AsIntoIter;
+pub(crate) use self::in_place_collect::AsVecIntoIter;
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::into_iter::IntoIter;
mod is_zero;
#[cfg(not(no_global_oom_handling))]
-mod source_iter_marker;
+mod in_place_collect;
mod partial_eq;
/// vec.extend([1, 2, 3].iter().copied());
///
/// for x in &vec {
-/// println!("{}", x);
+/// println!("{x}");
/// }
/// assert_eq!(vec, [7, 1, 2, 3]);
/// ```
///
/// while let Some(top) = stack.pop() {
/// // Prints 3, 2, 1
-/// println!("{}", top);
+/// println!("{top}");
/// }
/// ```
///
#[cold]
#[inline(never)]
fn assert_failed(index: usize, len: usize) -> ! {
- panic!("swap_remove index (is {}) should be < len (is {})", index, len);
+ panic!("swap_remove index (is {index}) should be < len (is {len})");
}
let len = self.len();
#[cold]
#[inline(never)]
fn assert_failed(index: usize, len: usize) -> ! {
- panic!("insertion index (is {}) should be <= len (is {})", index, len);
+ panic!("insertion index (is {index}) should be <= len (is {len})");
}
let len = self.len();
#[inline(never)]
#[track_caller]
fn assert_failed(index: usize, len: usize) -> ! {
- panic!("removal index (is {}) should be < len (is {})", index, len);
+ panic!("removal index (is {index}) should be < len (is {len})");
}
let len = self.len();
/// Retains only the elements specified by the predicate.
///
- /// In other words, remove all elements `e` such that `f(&e)` returns `false`.
+ /// In other words, remove all elements `e` for which `f(&e)` returns `false`.
/// This method operates in place, visiting each element exactly once in the
/// original order, and preserves the order of the retained elements.
///
}
}
- /// Moves all the elements of `other` into `Self`, leaving `other` empty.
+ /// Moves all the elements of `other` into `self`, leaving `other` empty.
///
/// # Panics
///
}
}
- /// Appends elements to `Self` from other buffer.
+ /// Appends elements to `self` from other buffer.
#[cfg(not(no_global_oom_handling))]
#[inline]
unsafe fn append_elements(&mut self, other: *const [T]) {
self.len += count;
}
- /// Creates a draining iterator that removes the specified range in the vector
- /// and yields the removed items.
+ /// Removes the specified range from the vector in bulk, returning all
+ /// removed elements as an iterator. If the iterator is dropped before
+ /// being fully consumed, it drops the remaining removed elements.
///
- /// When the iterator **is** dropped, all elements in the range are removed
- /// from the vector, even if the iterator was not fully consumed. If the
- /// iterator **is not** dropped (with [`mem::forget`] for example), it is
- /// unspecified how many elements are removed.
+ /// The returned iterator keeps a mutable borrow on the vector to optimize
+ /// its implementation.
///
/// # Panics
///
/// Panics if the starting point is greater than the end point or if
/// the end point is greater than the length of the vector.
///
+ /// # Leaking
+ ///
+ /// If the returned iterator goes out of scope without being dropped (due to
+ /// [`mem::forget`], for example), the vector may have lost and leaked
+ /// elements arbitrarily, including elements outside the range.
+ ///
/// # Examples
///
/// ```
/// assert_eq!(v, &[1]);
/// assert_eq!(u, &[2, 3]);
///
- /// // A full range clears the vector
+ /// // A full range clears the vector, like `clear()` does
/// v.drain(..);
/// assert_eq!(v, &[]);
/// ```
#[cold]
#[inline(never)]
fn assert_failed(at: usize, len: usize) -> ! {
- panic!("`at` split index (is {}) should be <= len (is {})", at, len);
+ panic!("`at` split index (is {at}) should be <= len (is {len})");
}
if at > self.len() {
/// let v = vec!["a".to_string(), "b".to_string()];
/// for s in v.into_iter() {
/// // s has type String, not &String
- /// println!("{}", s);
+ /// println!("{s}");
/// }
/// ```
#[inline]