Skip to content

Commit

Permalink
Merge #634
Browse files Browse the repository at this point in the history
634: Improved docstrings for `free::chain` r=phimuemue a=JoelMon

Improved the description of the function and added example.

Co-authored-by: Joel Montes de Oca <6587811+JoelMon@users.noreply.github.com>
  • Loading branch information
bors[bot] and JoelMon committed Aug 25, 2022
2 parents 4c0609a + 520765c commit 5ae7bb5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/free.rs
Expand Up @@ -128,16 +128,21 @@ pub fn zip<I, J>(i: I, j: J) -> Zip<I::IntoIter, J::IntoIter>
i.into_iter().zip(j)
}

/// Create an iterator that first iterates `i` and then `j`.

/// Takes two iterables and creates a new iterator over both in sequence.
///
/// [`IntoIterator`] enabled version of [`Iterator::chain`].
///
/// ## Example
/// ```
/// use itertools::chain;
///
/// let mut result:Vec<i32> = 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]);
/// ```
pub fn chain<I, J>(i: I, j: J) -> iter::Chain<<I as IntoIterator>::IntoIter, <J as IntoIterator>::IntoIter>
where I: IntoIterator,
Expand Down

0 comments on commit 5ae7bb5

Please sign in to comment.