From 676e4f193ce3842d55fd0406cfc957c1a617f317 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Fri, 2 Oct 2020 00:45:19 +0800 Subject: [PATCH] Add example for iter chain struct --- library/core/src/iter/adapters/chain.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/core/src/iter/adapters/chain.rs b/library/core/src/iter/adapters/chain.rs index 13c6a75d58b..658dae3825a 100644 --- a/library/core/src/iter/adapters/chain.rs +++ b/library/core/src/iter/adapters/chain.rs @@ -6,6 +6,17 @@ use crate::usize; /// /// 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<_>> = 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")]