diff options
| author | Alexis Bourget <alexis.bourget@gmail.com> | 2020-07-22 21:50:16 +0200 |
|---|---|---|
| committer | Alexis Bourget <alexis.bourget@gmail.com> | 2020-07-22 21:50:16 +0200 |
| commit | e601e2ac48a217fafb5962a43680d60c574d35ef (patch) | |
| tree | 7451f54da2460dd61752e99d0165f8db3afd6d4d /src/liballoc | |
| parent | 8ad7bc3f428300aee6764f6e23527e19eb235e81 (diff) | |
| download | rust-e601e2ac48a217fafb5962a43680d60c574d35ef.tar.gz rust-e601e2ac48a217fafb5962a43680d60c574d35ef.zip | |
Improve the documentation for Vec::drain
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/vec.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 5db96a504a6..269eeed3ccf 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1274,11 +1274,12 @@ impl<T> Vec<T> { /// Creates a draining iterator that removes the specified range in the vector /// and yields the removed items. /// - /// Note 1: The element range is removed even if the iterator is only - /// partially consumed or not consumed at all. + /// The element range is removed even if the iterator is only partially + /// consumed or not consumed at all. /// - /// Note 2: It is unspecified how many elements are removed from the vector - /// if the `Drain` value is leaked. + /// Note: Be aware that if the iterator is leaked (eg: [`mem::forget`]), it + /// cancels this property so it is unspecified how many elements are removed + /// from the vector in this case. /// /// # Panics /// @@ -1297,6 +1298,8 @@ impl<T> Vec<T> { /// v.drain(..); /// assert_eq!(v, &[]); /// ``` + /// + /// [`mem::forget`]: mem::forget #[stable(feature = "drain", since = "1.6.0")] pub fn drain<R>(&mut self, range: R) -> Drain<'_, T> where |
