From 1ad51cb36690cf7d7ed9eb5929d33f1c32d4262a Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 24 May 2023 10:47:06 +1200 Subject: [PATCH] Add par_iter_mut shim --- src/rayon.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/rayon.rs b/src/rayon.rs index ae1914c2b..210106684 100644 --- a/src/rayon.rs +++ b/src/rayon.rs @@ -26,6 +26,12 @@ pub trait IntoParallelRefIterator<'data> { fn par_iter(&'data self) -> Self::Iter; } +pub trait IntoParallelRefMutIterator<'data> { + type Iter: ParallelIterator; + type Item: Send + 'data; + fn par_iter_mut(&'data mut self) -> Self::Iter; +} + impl IntoParallelIterator for I where I::Item: Send, @@ -50,6 +56,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 ParallelIterator for I {} #[allow(dead_code)]