I try to use rayon.ParallelBridge
with iterator produced by itertoos.Itertools.group_by()
:
use rayon::prelude::*;
use itertools::Itertools;
fn main() {
let s: i32 = [0, 1, 2, -3, -4, -5, 6, 7, 8, 9, -10]
.iter()
.group_by(|&x| *x >= 0)
.into_iter()
.par_bridge()
.map(|(_key, group)| group.sum::<i32>())
.sum();
println!("{}", s);
}
error[E0599]: no method named `par_bridge` found for type `itertools::groupbylazy::Groups<'_, bool, std::slice::Iter<'_, {integer}>, [closure@src/main.rs:7:19: 7:31]>` in the current scope
--> src/main.rs:9:10
|
9 | .par_bridge()
| ^^^^^^^^^^
|
= note: the method `par_bridge` exists but the following trait bounds were not satisfied:
`&itertools::groupbylazy::Groups<'_, bool, std::slice::Iter<'_, {integer}>, [closure@src/main.rs:7:19: 7:31]> : rayon::iter::par_bridge::ParallelBridge`
`&mut itertools::groupbylazy::Groups<'_, bool, std::slice::Iter<'_, {integer}>, [closure@src/main.rs:7:19: 7:31]> : rayon::iter::par_bridge::ParallelBridge`
`itertools::groupbylazy::Groups<'_, bool, std::slice::Iter<'_, {integer}>, [closure@src/main.rs:7:19: 7:31]> : rayon::iter::par_bridge::ParallelBridge`
Can you help, what particular bound isn't satisfied? into_iter()
should return Iterator
while rayon.ParallelBridge
is implemented for Iterator