Skip to content

Commit 5ae7bb5

Browse files
bors[bot]JoelMon
andauthored
Merge #634
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 <[email protected]>
2 parents 4c0609a + 520765c commit 5ae7bb5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/free.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,21 @@ pub fn zip<I, J>(i: I, j: J) -> Zip<I::IntoIter, J::IntoIter>
128128
i.into_iter().zip(j)
129129
}
130130

131-
/// Create an iterator that first iterates `i` and then `j`.
131+
132+
/// Takes two iterables and creates a new iterator over both in sequence.
132133
///
133134
/// [`IntoIterator`] enabled version of [`Iterator::chain`].
134135
///
136+
/// ## Example
135137
/// ```
136138
/// use itertools::chain;
139+
///
140+
/// let mut result:Vec<i32> = Vec::new();
137141
///
138-
/// for elt in chain(&[1, 2, 3], &[4]) {
139-
/// /* loop body */
142+
/// for element in chain(&[1, 2, 3], &[4]) {
143+
/// result.push(*element);
140144
/// }
145+
/// assert_eq!(result, vec![1, 2, 3, 4]);
141146
/// ```
142147
pub fn chain<I, J>(i: I, j: J) -> iter::Chain<<I as IntoIterator>::IntoIter, <J as IntoIterator>::IntoIter>
143148
where I: IntoIterator,

0 commit comments

Comments
 (0)