@@ -1215,21 +1215,25 @@ impl<T, A: Allocator> VecDeque<T, A> {
12151215 unsafe { IterMut :: new ( ring, tail, head, PhantomData ) }
12161216 }
12171217
1218- /// Creates a draining iterator that removes the specified range in the
1219- /// deque and yields the removed items.
1218+ /// Removes the specified range from the deque in bulk, returning all
1219+ /// removed elements as an iterator. If the iterator is dropped before
1220+ /// being fully consumed, it drops the remaining removed elements.
12201221 ///
1221- /// Note 1: The element range is removed even if the iterator is not
1222- /// consumed until the end .
1222+ /// The returned iterator keeps a mutable borrow on the queue to optimize
1223+ /// its implementation .
12231224 ///
1224- /// Note 2: It is unspecified how many elements are removed from the deque,
1225- /// if the `Drain` value is not dropped, but the borrow it holds expires
1226- /// (e.g., due to `mem::forget`).
12271225 ///
12281226 /// # Panics
12291227 ///
12301228 /// Panics if the starting point is greater than the end point or if
12311229 /// the end point is greater than the length of the deque.
12321230 ///
1231+ /// # Leaking
1232+ ///
1233+ /// If the returned iterator goes out of scope without being dropped (due to
1234+ /// [`mem::forget`], for example), the deque may have lost and leaked
1235+ /// elements arbitrarily, including elements outside the range.
1236+ ///
12331237 /// # Examples
12341238 ///
12351239 /// ```
@@ -1240,7 +1244,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
12401244 /// assert_eq!(drained, [3]);
12411245 /// assert_eq!(deque, [1, 2]);
12421246 ///
1243- /// // A full range clears all contents
1247+ /// // A full range clears all contents, like `clear()` does
12441248 /// deque.drain(..);
12451249 /// assert!(deque.is_empty());
12461250 /// ```
0 commit comments