Skip to content

Commit

Permalink
Add par_iter_mut shim
Browse files Browse the repository at this point in the history
  • Loading branch information
andrews05 committed May 23, 2023
1 parent 67f93db commit 5eb3ee0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/rayon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ pub trait IntoParallelRefIterator<'data> {
fn par_iter(&'data self) -> Self::Iter;
}

pub trait IntoParallelRefMutIterator<'data> {
type Iter: ParallelIterator<Item = Self::Item>;
type Item: Send + 'data;

// Required method
fn par_iter_mut(&'data mut self) -> Self::Iter;
}

impl<I: IntoIterator> IntoParallelIterator for I
where
I::Item: Send,
Expand All @@ -50,6 +58,18 @@ where
}
}

impl<'data, I: 'data + ?Sized> IntoParallelRefMutIterator<'data> for I
where
&'data mut I: IntoParallelIterator,
{
type Iter = <&'data mut I as IntoParallelIterator>::Iter;
type Item = <&'data mut I as IntoParallelIterator>::Item;

fn par_iter_mut(&'data mut self) -> Self::Iter {
self.into_par_iter()
}
}

impl<I: Iterator> ParallelIterator for I {}

#[allow(dead_code)]
Expand Down

0 comments on commit 5eb3ee0

Please sign in to comment.