@@ -45,15 +45,23 @@ impl<A: Iterator, B: Iterator> Zip<A, B> {
45
45
///
46
46
/// let xs = [1, 2, 3];
47
47
/// let ys = [4, 5, 6];
48
- /// for (x, y) in zip(&xs, &ys) {
49
- /// println!("x:{}, y:{}", x, y);
50
- /// }
48
+ ///
49
+ /// let mut iter = zip(xs, ys);
50
+ ///
51
+ /// assert_eq!(iter.next().unwrap(), (1, 4));
52
+ /// assert_eq!(iter.next().unwrap(), (2, 5));
53
+ /// assert_eq!(iter.next().unwrap(), (3, 6));
54
+ /// assert!(iter.next().is_none());
51
55
///
52
56
/// // Nested zips are also possible:
53
57
/// let zs = [7, 8, 9];
54
- /// for ((x, y), z) in zip(zip(&xs, &ys), &zs) {
55
- /// println!("x:{}, y:{}, z:{}", x, y, z);
56
- /// }
58
+ ///
59
+ /// let mut iter = zip(zip(xs, ys), zs);
60
+ ///
61
+ /// assert_eq!(iter.next().unwrap(), ((1, 4), 7));
62
+ /// assert_eq!(iter.next().unwrap(), ((2, 5), 8));
63
+ /// assert_eq!(iter.next().unwrap(), ((3, 6), 9));
64
+ /// assert!(iter.next().is_none());
57
65
/// ```
58
66
#[ unstable( feature = "iter_zip" , issue = "83574" ) ]
59
67
pub fn zip < A , B > ( a : A , b : B ) -> Zip < A :: IntoIter , B :: IntoIter >
0 commit comments