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

Is this library support parallel iterator? #296

Open
hzqd opened this issue Jan 13, 2023 · 3 comments
Open

Is this library support parallel iterator? #296

hzqd opened this issue Jan 13, 2023 · 3 comments

Comments

@hzqd
Copy link

hzqd commented Jan 13, 2023

Or plans to support this feature?

@mbrubeck
Copy link
Collaborator

I don't have any specific plans, but would be happy to accept a patch adding rayon::IntoParallelIterator support.

@Owen-CH-Leung
Copy link

I believe ParallelIterator is already possible with SmallVec due to dereference coercion. For example:

let mut v: SmallVec<u8, 10> = smallvec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
println!("{:?}", v.into_par_iter());

will invoke this:

https://github.com/rayon-rs/rayon/blob/master/src/slice/mod.rs#L671-L678

And I believe the existing ParallelIterator implementation provided by rayon should be sufficient ? If not, please let me know. Happy to contribute

@haydnv
Copy link

haydnv commented Oct 31, 2023

This would be useful in cases where it's not possible to iterate over a value borrowed from a SmallVec, e.g.

let output = input
    .par_chunks(4)
    .map(SmallVec::from_slice) // the lifetime of this SmallVec is less than the iterator itself
    .map(do_something)
    .flatten() // this won't work since SmallVec itself doesn't implement `into_par_iter`
    .collect();

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

No branches or pull requests

4 participants