Skip to content

Commit 7a27408

Browse files
bors[bot]JoelMon
andauthored
Merge #632
632: Added body to free::zip's doc example r=phimuemue a=JoelMon Added body to the code example in the docs for free::zip. The code body added uses two types to make it obvious how `zip` functions. Co-authored-by: Joel Montes de Oca <6587811+JoelMon@users.noreply.github.com>
2 parents 6b7063a + 9150cab commit 7a27408

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/free.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,14 @@ pub fn rev<I>(iterable: I) -> iter::Rev<I::IntoIter>
112112
/// ```
113113
/// use itertools::zip;
114114
///
115-
/// let data = [1, 2, 3, 4, 5];
116-
/// for (a, b) in zip(&data, &data[1..]) {
117-
/// /* loop body */
115+
/// let data_1 = [1, 2, 3, 4, 5];
116+
/// let data_2 = ['a', 'b', 'c'];
117+
/// let mut result: Vec<(i32, char)> = Vec::new();
118+
///
119+
/// for (a, b) in zip(&data_1, &data_2) {
120+
/// result.push((*a, *b));
118121
/// }
122+
/// assert_eq!(result, vec![(1, 'a'),(2, 'b'),(3, 'c')]);
119123
/// ```
120124
pub fn zip<I, J>(i: I, j: J) -> Zip<I::IntoIter, J::IntoIter>
121125
where I: IntoIterator,

0 commit comments

Comments
 (0)