Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using itertools::Tuples with rayon #659

Closed
bobi6666 opened this issue Nov 21, 2022 · 1 comment
Closed

using itertools::Tuples with rayon #659

bobi6666 opened this issue Nov 21, 2022 · 1 comment
Labels

Comments

@bobi6666
Copy link

hello, I would like to use rayon::Tuples with rayon into_par_iter, could you tell me how it would be possible to provide an example of how to implement it?

@Philippe-Cholet
Copy link
Member

It's more about rayon than itertools but I think the general solution to this is par_bridge.

use itertools::Itertools;
use rayon::prelude::*;

fn main() {
    let v: Vec<_> = (0..1000)
        .tuples()
        .par_bridge()
        .map(|(x, y)| x + y)
        .collect();
    println!("{:?}", v);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants