Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
FEAT: Add internal Zip::last_producer
This method is useful for parallel Zip.
  • Loading branch information
bluss committed May 19, 2020
commit fe2ebf6eb96a191231751ebae65e76ab94476e76
13 changes: 13 additions & 0 deletions src/zip/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,11 @@ zipt_impl! {
[A B C D E F][ a b c d e f],
}

macro_rules! last_of {
($q:ty) => { $q };
($p:ty, $($q:ty),+) => { last_of!($($q),+) };
}

macro_rules! map_impl {
($([$notlast:ident $($p:ident)*],)+) => {
$(
Expand Down Expand Up @@ -1012,6 +1017,14 @@ macro_rules! map_impl {
}).is_done()
}

#[cfg(feature = "rayon")]
#[allow(dead_code)] // unused for the first of the Zip arities
/// Return a reference to the last producer
pub(crate) fn last_producer(&self) -> &last_of!($($p),*) {
let (.., ref last) = &self.parts;
last
}

expand_if!(@bool [$notlast]

/// Include the producer `p` in the Zip.
Expand Down