diff --git a/src/free.rs b/src/free.rs index d93eb2bef..041bbdb26 100644 --- a/src/free.rs +++ b/src/free.rs @@ -128,17 +128,23 @@ pub fn zip(i: I, j: J) -> Zip i.into_iter().zip(j) } -/// Create an iterator that first iterates `i` and then `j`. + +/// Takes two iterators and creates a new iterator over both in sequence. /// /// [`IntoIterator`] enabled version of [`Iterator::chain`]. /// +/// ## Example /// ``` /// use itertools::chain; +/// +/// let mut result:Vec = Vec::new(); /// -/// for elt in chain(&[1, 2, 3], &[4]) { -/// /* loop body */ +/// for element in chain(&[1, 2, 3] , &[4]) { +/// result.push(*element); /// } +/// assert_eq!(result, vec![1, 2, 3, 4]); /// ``` +#[deprecated(note="Use std::iter::Chain instead", since="1.0.0")] pub fn chain(i: I, j: J) -> iter::Chain<::IntoIter, ::IntoIter> where I: IntoIterator, J: IntoIterator diff --git a/src/lib.rs b/src/lib.rs index 5cca5d99f..f91968870 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2271,7 +2271,7 @@ pub trait Itertools : Iterator { /// ``` /// /// Which, for non-associative functions, will typically produce a different - /// result than the linear call tree used by `fold1`: + /// result than the linear call tree used by [`Iterator::reduce`]: /// /// ```text /// 1 2 3 4 5 6 7 @@ -2279,7 +2279,7 @@ pub trait Itertools : Iterator { /// └─f─f─f─f─f─f /// ``` /// - /// If `f` is associative, prefer the normal `fold1` instead. + /// If `f` is associative, prefer the normal [`Iterator::reduce`] instead. /// /// ``` /// use itertools::Itertools;