]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #77409 - pickfire:patch-6, r=GuillaumeGomez
authorJonas Schievink <jonasschievink@gmail.com>
Fri, 2 Oct 2020 18:27:06 +0000 (20:27 +0200)
committerGitHub <noreply@github.com>
Fri, 2 Oct 2020 18:27:06 +0000 (20:27 +0200)
Add example for iter chain struct

r? @GuillaumeGomez

library/core/src/iter/adapters/chain.rs

index 13c6a75d58b5c101512308fac928784d7fa4cad9..ac27ec19b3688a6cb634b55f6c1a6973a2af8078 100644 (file)
@@ -6,6 +6,17 @@
 ///
 /// This `struct` is created by [`Iterator::chain`]. See its documentation
 /// for more.
+///
+/// # Examples
+///
+/// ```
+/// use std::iter::Chain;
+/// use std::slice::Iter;
+///
+/// let a1 = [1, 2, 3];
+/// let a2 = [4, 5, 6];
+/// let iter: Chain<Iter<_>, Iter<_>> = a1.iter().chain(a2.iter());
+/// ```
 #[derive(Clone, Debug)]
 #[must_use = "iterators are lazy and do nothing unless consumed"]
 #[stable(feature = "rust1", since = "1.0.0")]