@@ -1215,21 +1215,25 @@ impl<T, A: Allocator> VecDeque<T, A> {
1215
1215
unsafe { IterMut :: new ( ring, tail, head, PhantomData ) }
1216
1216
}
1217
1217
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.
1220
1221
///
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 .
1223
1224
///
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`).
1227
1225
///
1228
1226
/// # Panics
1229
1227
///
1230
1228
/// Panics if the starting point is greater than the end point or if
1231
1229
/// the end point is greater than the length of the deque.
1232
1230
///
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
+ ///
1233
1237
/// # Examples
1234
1238
///
1235
1239
/// ```
@@ -1240,7 +1244,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
1240
1244
/// assert_eq!(drained, [3]);
1241
1245
/// assert_eq!(deque, [1, 2]);
1242
1246
///
1243
- /// // A full range clears all contents
1247
+ /// // A full range clears all contents, like `clear()` does
1244
1248
/// deque.drain(..);
1245
1249
/// assert!(deque.is_empty());
1246
1250
/// ```
0 commit comments