@@ -214,12 +214,15 @@ macro_rules! iproduct {
214
214
/// returns `None`.
215
215
///
216
216
/// This is a version of the standard ``.zip()`` that's supporting more than
217
- /// two iterators. The iterator elment type is a tuple with one element
217
+ /// two iterators. The iterator element type is a tuple with one element
218
218
/// from each of the input iterators. Just like ``.zip()``, the iteration stops
219
219
/// when the shortest of the inputs reaches its end.
220
220
///
221
- /// **Note:** The result of this macro is an iterator composed of
222
- /// repeated `.zip()` and a `.map()`; it has an anonymous type.
221
+ /// **Note:** The result of this macro is in the general case an iterator
222
+ /// composed of repeated `.zip()` and a `.map()`; it has an anonymous type.
223
+ /// The special cases of one and two arguments produce the equivalent of
224
+ /// `$a.into_iter()` and `$a.into_iter().zip($b)` respectively.
225
+ ///
223
226
/// Prefer this macro `izip!()` over [`multizip`] for the performance benefits
224
227
/// of using the standard library `.zip()`.
225
228
///
@@ -261,8 +264,20 @@ macro_rules! izip {
261
264
izip!( @closure ( $p, b) => ( $( $tup) * , b ) $( , $tail ) * )
262
265
} ;
263
266
264
- ( $first: expr $( , $rest: expr ) * $( , ) * ) => {
267
+ // unary
268
+ ( $first: expr $( , ) * ) => {
265
269
$crate:: __std_iter:: IntoIterator :: into_iter( $first)
270
+ } ;
271
+
272
+ // binary
273
+ ( $first: expr, $second: expr $( , ) * ) => {
274
+ izip!( $first)
275
+ . zip( $second)
276
+ } ;
277
+
278
+ // n-ary where n > 2
279
+ ( $first: expr $( , $rest: expr ) * $( , ) * ) => {
280
+ izip!( $first)
266
281
$(
267
282
. zip( $rest)
268
283
) *
0 commit comments