@@ -514,9 +514,40 @@ pub trait Iterator {
514
514
/// assert_eq!((2, 'o'), enumerate[2]);
515
515
/// assert_eq!((2, 'o'), zipper[2]);
516
516
/// ```
517
+ /// If both iterators have roughly equivalent syntax, it may me more readable to use [`zip`]:
518
+ /// ```
519
+ /// # use std::iter::zip;
520
+ /// let a = [1, 2, 3];
521
+ /// let b = [2, 3, 4];
522
+ ///
523
+ /// let mut zipped = zip(
524
+ /// a.into_iter().map(|x| x * 2).skip(1),
525
+ /// b.into_iter().map(|x| x * 2).skip(1),
526
+ /// );
527
+ ///
528
+ /// assert_eq!(zipped.next(), Some((4, 6)));
529
+ /// assert_eq!(zipped.next(), Some((6, 8)));
530
+ /// assert_eq!(zipped.next(), None);
531
+ /// ```
532
+ /// compared to:
533
+ /// ```
534
+ /// let a = [1, 2, 3];
535
+ /// let b = [2, 3, 4];
536
+ ///
537
+ /// let mut zipped = a
538
+ /// .into_iter()
539
+ /// .map(|x| x * 2)
540
+ /// .skip(1)
541
+ /// .zip(b.into_iter().map(|x| x * 2).skip(1));
542
+ ///
543
+ /// assert_eq!(zipped.next(), Some((4, 6)));
544
+ /// assert_eq!(zipped.next(), Some((6, 8)));
545
+ /// assert_eq!(zipped.next(), None);
546
+ /// ```
517
547
///
518
548
/// [`enumerate`]: Iterator::enumerate
519
549
/// [`next`]: Iterator::next
550
+ /// [`zip`]: crate::iter::zip
520
551
#[ inline]
521
552
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
522
553
fn zip < U > ( self , other : U ) -> Zip < Self , U :: IntoIter >
0 commit comments