aboutsummaryrefslogtreecommitdiff
path: root/src/free.rs
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2022-12-12 22:29:29 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-12-12 22:29:29 +0000
commit24d8819288d38db197610f3872f14dea3f3d2305 (patch)
tree8e0a28233ae31fcd4f59965958c208c3cbb61ee4 /src/free.rs
parent9812a387147ac7bf57a7f04108fbab3afeb2137a (diff)
parent5a03ba3cb246bc0cc1d8514e1323a0426304ad1d (diff)
downloaditertools-24d8819288d38db197610f3872f14dea3f3d2305.tar.gz
Merge "Upgrade itertools to 0.10.5" am: 79f88bdd7d am: d83b1d14f2 am: 5a03ba3cb2
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/itertools/+/2344982 Change-Id: I49d1dcd7776b98c77c68bfd4c35a8125f7417b7d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'src/free.rs')
-rw-r--r--src/free.rs26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/free.rs b/src/free.rs
index 6674030..19e3e28 100644
--- a/src/free.rs
+++ b/src/free.rs
@@ -105,18 +105,23 @@ pub fn rev<I>(iterable: I) -> iter::Rev<I::IntoIter>
iterable.into_iter().rev()
}
-/// Iterate `i` and `j` in lock step.
+/// Converts the arguments to iterators and zips them.
///
/// [`IntoIterator`] enabled version of [`Iterator::zip`].
+///
+/// ## Example
///
/// ```
/// use itertools::zip;
///
-/// let data = [1, 2, 3, 4, 5];
-/// for (a, b) in zip(&data, &data[1..]) {
-/// /* loop body */
+/// let mut result: Vec<(i32, char)> = Vec::new();
+///
+/// for (a, b) in zip(&[1, 2, 3, 4, 5], &['a', 'b', 'c']) {
+/// result.push((*a, *b));
/// }
+/// assert_eq!(result, vec![(1, 'a'),(2, 'b'),(3, 'c')]);
/// ```
+#[deprecated(note="Use [std::iter::zip](https://doc.rust-lang.org/std/iter/fn.zip.html) instead", since="0.10.4")]
pub fn zip<I, J>(i: I, j: J) -> Zip<I::IntoIter, J::IntoIter>
where I: IntoIterator,
J: IntoIterator
@@ -124,16 +129,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,
@@ -239,7 +249,7 @@ pub fn min<I>(iterable: I) -> Option<I::Item>
}
-/// Combine all iterator elements into one String, seperated by `sep`.
+/// Combine all iterator elements into one String, separated by `sep`.
///
/// [`IntoIterator`] enabled version of [`Itertools::join`].
///