Skip to content

Commit e601e2a

Browse files
committed
Improve the documentation for Vec::drain
1 parent 8ad7bc3 commit e601e2a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/liballoc/vec.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1274,11 +1274,12 @@ impl<T> Vec<T> {
12741274
/// Creates a draining iterator that removes the specified range in the vector
12751275
/// and yields the removed items.
12761276
///
1277-
/// Note 1: The element range is removed even if the iterator is only
1278-
/// partially consumed or not consumed at all.
1277+
/// The element range is removed even if the iterator is only partially
1278+
/// consumed or not consumed at all.
12791279
///
1280-
/// Note 2: It is unspecified how many elements are removed from the vector
1281-
/// if the `Drain` value is leaked.
1280+
/// Note: Be aware that if the iterator is leaked (eg: [`mem::forget`]), it
1281+
/// cancels this property so it is unspecified how many elements are removed
1282+
/// from the vector in this case.
12821283
///
12831284
/// # Panics
12841285
///
@@ -1297,6 +1298,8 @@ impl<T> Vec<T> {
12971298
/// v.drain(..);
12981299
/// assert_eq!(v, &[]);
12991300
/// ```
1301+
///
1302+
/// [`mem::forget`]: mem::forget
13001303
#[stable(feature = "drain", since = "1.6.0")]
13011304
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>
13021305
where

0 commit comments

Comments
 (0)