@@ -4,8 +4,8 @@ use crate::ops::Try;
44
55/// An iterator that links two iterators together, in a chain.
66///
7- /// This `struct` is created by [`Iterator::chain`]. See its documentation
8- /// for more.
7+ /// This `struct` is created by [`chain`] or [` Iterator::chain`]. See their
8+ /// documentation for more.
99///
1010/// # Examples
1111///
@@ -38,6 +38,39 @@ impl<A, B> Chain<A, B> {
3838 }
3939}
4040
41+ /// Converts the arguments to iterators and links them together, in a chain.
42+ ///
43+ /// See the documentation of [`Iterator::chain`] for more.
44+ ///
45+ /// # Examples
46+ ///
47+ /// ```
48+ /// #![feature(iter_chain)]
49+ ///
50+ /// use std::iter::chain;
51+ ///
52+ /// let a = [1, 2, 3];
53+ /// let b = [4, 5, 6];
54+ ///
55+ /// let mut iter = chain(a, b);
56+ ///
57+ /// assert_eq!(iter.next(), Some(1));
58+ /// assert_eq!(iter.next(), Some(2));
59+ /// assert_eq!(iter.next(), Some(3));
60+ /// assert_eq!(iter.next(), Some(4));
61+ /// assert_eq!(iter.next(), Some(5));
62+ /// assert_eq!(iter.next(), Some(6));
63+ /// assert_eq!(iter.next(), None);
64+ /// ```
65+ #[ unstable( feature = "iter_chain" , reason = "recently added" , issue = "125964" ) ]
66+ pub fn chain < A , B > ( a : A , b : B ) -> Chain < A :: IntoIter , B :: IntoIter >
67+ where
68+ A : IntoIterator ,
69+ B : IntoIterator < Item = A :: Item > ,
70+ {
71+ Chain :: new ( a. into_iter ( ) , b. into_iter ( ) )
72+ }
73+
4174#[ stable( feature = "rust1" , since = "1.0.0" ) ]
4275impl < A , B > Iterator for Chain < A , B >
4376where
0 commit comments