-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug in the handling of producers
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 0.1.1 | ||
|
||
Fixed a bug in `MapfoldReduceProducerIter::next_back` discovered by @cuviper. | ||
|
||
# 0.1.0 | ||
|
||
Initial release! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
extern crate rayon; | ||
extern crate rayon_croissant; | ||
|
||
use rayon::prelude::{ParallelIterator, IndexedParallelIterator, IntoParallelRefIterator}; | ||
use rayon_croissant::ParallelIteratorExt; | ||
|
||
#[test] | ||
fn test_zip_rev() { | ||
let ingredients = &["jambon", "beurre", "fromage", "baguette"]; | ||
let scores = &[0, 1, 2, 3]; | ||
|
||
let mut names = vec![]; | ||
let rev_scores = ingredients | ||
.par_iter() | ||
.cloned() | ||
.zip(scores.par_iter().cloned()) | ||
.with_min_len(2) | ||
.mapfold_reduce_into( | ||
&mut names, | ||
|names, (name, score)| { | ||
names.push(name); | ||
score | ||
}, | ||
|left_names, mut right_names| { | ||
left_names.append(&mut right_names); | ||
}, | ||
) | ||
// Reversing *after* a call to mapfold_reduce_into shouldn't | ||
// change the result of the folding operation. | ||
.rev() | ||
.collect::<Vec<_>>(); | ||
|
||
assert_eq!(names, ingredients); | ||
assert_eq!(rev_scores, [3, 2, 1, 0]); | ||
} |