Skip to content

Commit 8e39062

Browse files
committed
Fix rayon implementations
1 parent aaa7964 commit 8e39062

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/external_trait_impls/rayon/raw.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::raw::Bucket;
2-
use crate::raw::{RawIterRange, RawTable};
2+
use crate::raw::{Alloc, RawIterRange, RawTable};
33
use crate::scopeguard::guard;
44
use alloc::alloc::dealloc;
55
use core::marker::PhantomData;
@@ -54,11 +54,11 @@ impl<T> UnindexedProducer for ParIterProducer<T> {
5454
}
5555

5656
/// Parallel iterator which consumes a table and returns elements.
57-
pub struct RawIntoParIter<T> {
58-
table: RawTable<T>,
57+
pub struct RawIntoParIter<T, A: Alloc + Clone> {
58+
table: RawTable<T, A>,
5959
}
6060

61-
impl<T: Send> ParallelIterator for RawIntoParIter<T> {
61+
impl<T: Send, A: Alloc + Clone> ParallelIterator for RawIntoParIter<T, A> {
6262
type Item = T;
6363

6464
#[cfg_attr(feature = "inline-more", inline)]
@@ -80,16 +80,16 @@ impl<T: Send> ParallelIterator for RawIntoParIter<T> {
8080
}
8181

8282
/// Parallel iterator which consumes elements without freeing the table storage.
83-
pub struct RawParDrain<'a, T> {
83+
pub struct RawParDrain<'a, T, A: Alloc + Clone> {
8484
// We don't use a &'a mut RawTable<T> because we want RawParDrain to be
8585
// covariant over T.
86-
table: NonNull<RawTable<T>>,
87-
marker: PhantomData<&'a RawTable<T>>,
86+
table: NonNull<RawTable<T, A>>,
87+
marker: PhantomData<&'a RawTable<T, A>>,
8888
}
8989

90-
unsafe impl<T> Send for RawParDrain<'_, T> {}
90+
unsafe impl<T, A: Alloc + Clone> Send for RawParDrain<'_, T, A> {}
9191

92-
impl<T: Send> ParallelIterator for RawParDrain<'_, T> {
92+
impl<T: Send, A: Alloc + Clone> ParallelIterator for RawParDrain<'_, T, A> {
9393
type Item = T;
9494

9595
#[cfg_attr(feature = "inline-more", inline)]
@@ -107,7 +107,7 @@ impl<T: Send> ParallelIterator for RawParDrain<'_, T> {
107107
}
108108
}
109109

110-
impl<T> Drop for RawParDrain<'_, T> {
110+
impl<T, A: Alloc + Clone> Drop for RawParDrain<'_, T, A> {
111111
fn drop(&mut self) {
112112
// If drive_unindexed is not called then simply clear the table.
113113
unsafe { self.table.as_mut().clear() }
@@ -166,7 +166,7 @@ impl<T> Drop for ParDrainProducer<T> {
166166
}
167167
}
168168

169-
impl<T> RawTable<T> {
169+
impl<T, A: Alloc + Clone> RawTable<T, A> {
170170
/// Returns a parallel iterator over the elements in a `RawTable`.
171171
#[cfg_attr(feature = "inline-more", inline)]
172172
pub fn par_iter(&self) -> RawParIter<T> {
@@ -177,14 +177,14 @@ impl<T> RawTable<T> {
177177

178178
/// Returns a parallel iterator over the elements in a `RawTable`.
179179
#[cfg_attr(feature = "inline-more", inline)]
180-
pub fn into_par_iter(self) -> RawIntoParIter<T> {
180+
pub fn into_par_iter(self) -> RawIntoParIter<T, A> {
181181
RawIntoParIter { table: self }
182182
}
183183

184184
/// Returns a parallel iterator which consumes all elements of a `RawTable`
185185
/// without freeing its memory allocation.
186186
#[cfg_attr(feature = "inline-more", inline)]
187-
pub fn par_drain(&mut self) -> RawParDrain<'_, T> {
187+
pub fn par_drain(&mut self) -> RawParDrain<'_, T, A> {
188188
RawParDrain {
189189
table: NonNull::from(self),
190190
marker: PhantomData,

src/raw/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ cfg_if! {
3232
}
3333

3434
mod alloc;
35-
use self::alloc::Alloc;
36-
pub use self::alloc::Global;
35+
pub use self::alloc::{Alloc, Global};
3736

3837
mod bitmask;
3938

0 commit comments

Comments
 (0)