summaryrefslogtreecommitdiffstats
path: root/vendor/itertools/src/free.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:13:23 +0000
commit20431706a863f92cb37dc512fef6e48d192aaf2c (patch)
tree2867f13f5fd5437ba628c67d7f87309ccadcd286 /vendor/itertools/src/free.rs
parentReleasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff)
downloadrustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz
rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.zip
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--vendor/itertools/src/free.rs26
1 files changed, 18 insertions, 8 deletions
diff --git a/vendor/itertools/src/free.rs b/vendor/itertools/src/free.rs
index 667403040..19e3e2869 100644
--- a/vendor/itertools/src/free.rs
+++ b/vendor/itertools/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`].
///