Improve the documentation for Vec::drain
This commit is contained in:
parent
8ad7bc3f42
commit
e601e2ac48
1 changed files with 7 additions and 4 deletions
|
@ -1274,11 +1274,12 @@ impl<T> Vec<T> {
|
||||||
/// Creates a draining iterator that removes the specified range in the vector
|
/// Creates a draining iterator that removes the specified range in the vector
|
||||||
/// and yields the removed items.
|
/// and yields the removed items.
|
||||||
///
|
///
|
||||||
/// Note 1: The element range is removed even if the iterator is only
|
/// The element range is removed even if the iterator is only partially
|
||||||
/// partially consumed or not consumed at all.
|
/// consumed or not consumed at all.
|
||||||
///
|
///
|
||||||
/// Note 2: It is unspecified how many elements are removed from the vector
|
/// Note: Be aware that if the iterator is leaked (eg: [`mem::forget`]), it
|
||||||
/// if the `Drain` value is leaked.
|
/// cancels this property so it is unspecified how many elements are removed
|
||||||
|
/// from the vector in this case.
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
|
@ -1297,6 +1298,8 @@ impl<T> Vec<T> {
|
||||||
/// v.drain(..);
|
/// v.drain(..);
|
||||||
/// assert_eq!(v, &[]);
|
/// assert_eq!(v, &[]);
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// [`mem::forget`]: mem::forget
|
||||||
#[stable(feature = "drain", since = "1.6.0")]
|
#[stable(feature = "drain", since = "1.6.0")]
|
||||||
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>
|
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>
|
||||||
where
|
where
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue