Skip to content

Commit fe2ebf6

Browse files
committed
FEAT: Add internal Zip::last_producer
This method is useful for parallel Zip.
1 parent ee97dbf commit fe2ebf6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/zip/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,11 @@ zipt_impl! {
916916
[A B C D E F][ a b c d e f],
917917
}
918918

919+
macro_rules! last_of {
920+
($q:ty) => { $q };
921+
($p:ty, $($q:ty),+) => { last_of!($($q),+) };
922+
}
923+
919924
macro_rules! map_impl {
920925
($([$notlast:ident $($p:ident)*],)+) => {
921926
$(
@@ -1012,6 +1017,14 @@ macro_rules! map_impl {
10121017
}).is_done()
10131018
}
10141019

1020+
#[cfg(feature = "rayon")]
1021+
#[allow(dead_code)] // unused for the first of the Zip arities
1022+
/// Return a reference to the last producer
1023+
pub(crate) fn last_producer(&self) -> &last_of!($($p),*) {
1024+
let (.., ref last) = &self.parts;
1025+
last
1026+
}
1027+
10151028
expand_if!(@bool [$notlast]
10161029

10171030
/// Include the producer `p` in the Zip.

0 commit comments

Comments
 (0)