#[macro_export]
macro_rules! zip_with {
($($f:ident,)? ($e:expr $(, $rest:expr)*), $($move:ident)? |$($i:ident),+ $(,)?| $($work:tt)*) => {{
$crate::zip_with!($($f,)? ($e $(, $rest)*), map, $($move)? |$($i),+| $($work)*)
}};
($($f:ident,)? ($e:expr $(, $rest:expr)*), $worker:ident, $($move:ident,)? |$($i:ident),+ $(,)?| $($work:tt)*) => {{
$crate::zip_all!($($f,)? ($e $(, $rest)*))
.$worker($($move)? |$crate::nested_idents!($($i),+)| {
$($work)*
})
}};
}
#[macro_export]
macro_rules! zip_with_for_each {
($($f:ident,)? ($e:expr $(, $rest:expr)*), $($move:ident)? |$($i:ident),+ $(,)?| $($work:tt)*) => {{
$crate::zip_with!($($f,)? ($e $(, $rest)*), for_each, $($move)? |$($i),+| $($work)*)
}};
}
#[doc(hidden)]
#[macro_export]
macro_rules! nested_idents {
($a:ident, $b:ident) => {
($a, $b)
};
($first:ident, $($rest:ident),+) => {
($first, $crate::nested_idents!($($rest),+))
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! zip_all {
(($e:expr,)) => {
$e
};
($f:ident, ($e:expr,)) => {
$e.$f()
};
($f:ident, ($first:expr, $second:expr $(, $rest:expr)*)) => {
($first.$f().zip_eq($crate::zip_all!($f, ($second, $( $rest),*))))
};
(($first:expr, $second:expr $(, $rest:expr)*)) => {
($first.zip_eq($crate::zip_all!(($second, $( $rest),*))))
};
}