diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-09-23 14:54:10 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-23 14:54:10 +0200 |
| commit | b76343643dddfa17de98f5aa7ad3d24ef4b62f7b (patch) | |
| tree | 5d2352ecd7c6cf6d38d2a5ed5ac5b698c19ad6e1 | |
| parent | bcdbe79f0c3597849eb12617b9df4aab860a8ccf (diff) | |
| parent | 143557ec56124c246d6cf4c37398e657f84536e1 (diff) | |
| download | rust-b76343643dddfa17de98f5aa7ad3d24ef4b62f7b.tar.gz rust-b76343643dddfa17de98f5aa7ad3d24ef4b62f7b.zip | |
Rollup merge of #77017 - GuillaumeGomez:vec-missing-examples-iter, r=Dylan-DPC
Add missing examples on Vec iter types r? @Dylan-DPC
| -rw-r--r-- | library/alloc/src/vec.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index 8c0b6af5482..8a9463cb518 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -2849,6 +2849,13 @@ where /// /// This `struct` is created by the `into_iter` method on [`Vec`] (provided /// by the [`IntoIterator`] trait). +/// +/// # Example +/// +/// ``` +/// let v = vec![0, 1, 2]; +/// let iter: std::vec::IntoIter<_> = v.into_iter(); +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub struct IntoIter<T> { buf: NonNull<T>, @@ -3092,6 +3099,13 @@ impl<T> AsIntoIter for IntoIter<T> { /// /// This `struct` is created by [`Vec::drain`]. /// See its documentation for more. +/// +/// # Example +/// +/// ``` +/// let mut v = vec![0, 1, 2]; +/// let iter: std::vec::Drain<_> = v.drain(..); +/// ``` #[stable(feature = "drain", since = "1.6.0")] pub struct Drain<'a, T: 'a> { /// Index of tail to preserve @@ -3221,6 +3235,14 @@ impl<T> FusedIterator for Drain<'_, T> {} /// /// This struct is created by [`Vec::splice()`]. /// See its documentation for more. +/// +/// # Example +/// +/// ``` +/// let mut v = vec![0, 1, 2]; +/// let new = [7, 8]; +/// let iter: std::vec::Splice<_> = v.splice(1.., new.iter().cloned()); +/// ``` #[derive(Debug)] #[stable(feature = "vec_splice", since = "1.21.0")] pub struct Splice<'a, I: Iterator + 'a> { @@ -3337,6 +3359,15 @@ impl<T> Drain<'_, T> { /// /// This struct is created by [`Vec::drain_filter`]. /// See its documentation for more. +/// +/// # Example +/// +/// ``` +/// #![feature(drain_filter)] +/// +/// let mut v = vec![0, 1, 2]; +/// let iter: std::vec::DrainFilter<_, _> = v.drain_filter(|x| *x % 2 == 0); +/// ``` #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] #[derive(Debug)] pub struct DrainFilter<'a, T, F> |
