I'm working on a small library that has functions that take iterators as arguments. The functions are "embarrassingly parallel", so I decided to use Rayon to speed them up. However, I would like to accept either a Rayon ParallelIterator
or a std::iter::Iterator
, but there doesn't seem to be a way to accept both.
I can take an impl ParallelIterator
, which will work with Rayon iterators but not sequential iterators, or I can take an impl Iterator
, which will work with sequential iterators but not Rayon iterators.
I only use methods that are available on both Rayon and sequential iterators (only map
and collect
). Is there a way I can accept both?