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