Skip to content

Commit

Permalink
Docstring improvement: Added explanation of function
Browse files Browse the repository at this point in the history
The free::zip function had a short explanation. I went ahead
and fleshed it out a bit. I also placed the code example under the
`## Example` subheading.
  • Loading branch information
JoelMon committed Jul 11, 2022
1 parent 7a27408 commit 45f5826
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/free.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,19 @@ pub fn rev<I>(iterable: I) -> iter::Rev<I::IntoIter>
iterable.into_iter().rev()
}

/// Iterate `i` and `j` in lock step.
/// `zip()` returns a new array where each element is a tuple consisting
/// of elements from the _first_ and _second_ array. The returned array has as many elements
/// as the shortest of the two arrays passed in.
///
/// [`IntoIterator`] enabled version of [`Iterator::zip`].
///
/// ## Example
///
/// ```
/// use itertools::zip;
///
/// let data_1 = [1, 2, 3, 4, 5];
/// let data_2 = ['a', 'b', 'c'];
/// let data_1 = [1, 2, 3, 4, 5];
/// let data_2 = ['a', 'b', 'c'];
/// let mut result: Vec<(i32, char)> = Vec::new();
///
/// for (a, b) in zip(&data_1, &data_2) {
Expand Down

0 comments on commit 45f5826

Please sign in to comment.