From 2ca3c5ac72100a2579a942d4a51cf0a31df851bc Mon Sep 17 00:00:00 2001 From: Philippe-Cholet <44676486+Philippe-Cholet@users.noreply.github.com> Date: Tue, 21 May 2024 11:13:44 +0200 Subject: [PATCH] Macro hygiene: qualified paths only Is conflict with `.map` and `.zip` absolutely impossible? --- src/lib.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1a847d42b..018f877e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -262,7 +262,10 @@ macro_rules! iproduct { $crate::__std_iter::once(()) ); ($I:expr $(,)?) => ( - $crate::__std_iter::IntoIterator::into_iter($I).map(|elt| (elt,)) + $crate::__std_iter::Iterator::map( + $crate::__std_iter::IntoIterator::into_iter($I), + |elt| (elt,) + ) ); ($I:expr, $J:expr $(,)?) => ( $crate::Itertools::cartesian_product( @@ -330,19 +333,24 @@ macro_rules! izip { // binary ($first:expr, $second:expr $(,)*) => { - $crate::izip!($first) - .zip($second) + $crate::__std_iter::Iterator::zip( + $crate::__std_iter::IntoIterator::into_iter($first), + $second, + ) }; // n-ary where n > 2 ( $first:expr $( , $rest:expr )* $(,)* ) => { - $crate::izip!($first) + { + let iter = $crate::__std_iter::IntoIterator::into_iter($first); $( - .zip($rest) + let iter = $crate::__std_iter::Iterator::zip(iter, $rest); )* - .map( + $crate::__std_iter::Iterator::map( + iter, $crate::izip!(@closure a => (a) $( , $rest )*) ) + } }; }