Skip to content

Commit ef6a656

Browse files
committed
Fix clippy::needless_lifetimes and clippy::type_complexity in rayon
1 parent 97dbaea commit ef6a656

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/rayon/map.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,15 @@ pub(super) struct ParBuckets<'a, K, V> {
8383

8484
impl<'a, K, V> ParBuckets<'a, K, V> {
8585
pub(super) fn new(entries: &'a VecDeque<Bucket<K, V>>) -> Self {
86-
Self::from_slices(entries.as_slices())
86+
let (head, tail) = entries.as_slices();
87+
Self { head, tail }
8788
}
8889

89-
pub(super) fn from_slices((head, tail): (&'a [Bucket<K, V>], &'a [Bucket<K, V>])) -> Self {
90-
Self { head, tail }
90+
pub(super) fn from_slice(slice: &'a [Bucket<K, V>]) -> Self {
91+
Self {
92+
head: slice,
93+
tail: &[],
94+
}
9195
}
9296

9397
pub(super) fn iter(&self) -> impl Iterator<Item = &Bucket<K, V>> {
@@ -119,7 +123,7 @@ impl<'a, K: Sync, V: Sync> ParallelIterator for ParBuckets<'a, K, V> {
119123
}
120124
}
121125

122-
impl<'a, K: Sync, V: Sync> IndexedParallelIterator for ParBuckets<'a, K, V> {
126+
impl<K: Sync, V: Sync> IndexedParallelIterator for ParBuckets<'_, K, V> {
123127
fn drive<C>(self, consumer: C) -> C::Result
124128
where
125129
C: Consumer<Self::Item>,
@@ -167,7 +171,7 @@ where
167171

168172
fn into_par_iter(self) -> Self::Iter {
169173
ParIter {
170-
entries: ParBuckets::from_slices((&self.entries, &[])),
174+
entries: ParBuckets::from_slice(&self.entries),
171175
}
172176
}
173177
}
@@ -215,11 +219,15 @@ struct ParBucketsMut<'a, K, V> {
215219

216220
impl<'a, K, V> ParBucketsMut<'a, K, V> {
217221
fn new(entries: &'a mut VecDeque<Bucket<K, V>>) -> Self {
218-
Self::from_mut_slices(entries.as_mut_slices())
222+
let (head, tail) = entries.as_mut_slices();
223+
Self { head, tail }
219224
}
220225

221-
fn from_mut_slices((head, tail): (&'a mut [Bucket<K, V>], &'a mut [Bucket<K, V>])) -> Self {
222-
Self { head, tail }
226+
fn from_mut_slice(slice: &'a mut [Bucket<K, V>]) -> Self {
227+
Self {
228+
head: slice,
229+
tail: &mut [],
230+
}
223231
}
224232

225233
fn iter(&self) -> impl Iterator<Item = &Bucket<K, V>> {
@@ -245,7 +253,7 @@ impl<'a, K: Send, V: Send> ParallelIterator for ParBucketsMut<'a, K, V> {
245253
}
246254
}
247255

248-
impl<'a, K: Send, V: Send> IndexedParallelIterator for ParBucketsMut<'a, K, V> {
256+
impl<K: Send, V: Send> IndexedParallelIterator for ParBucketsMut<'_, K, V> {
249257
fn drive<C>(self, consumer: C) -> C::Result
250258
where
251259
C: Consumer<Self::Item>,
@@ -293,7 +301,7 @@ where
293301

294302
fn into_par_iter(self) -> Self::Iter {
295303
ParIterMut {
296-
entries: ParBucketsMut::from_mut_slices((&mut self.entries, &mut [])),
304+
entries: ParBucketsMut::from_mut_slice(&mut self.entries),
297305
}
298306
}
299307
}
@@ -407,7 +415,7 @@ where
407415
/// in the slice is still preserved for operations like `reduce` and `collect`.
408416
pub fn par_keys(&self) -> ParKeys<'_, K, V> {
409417
ParKeys {
410-
entries: ParBuckets::from_slices((&self.entries, &[])),
418+
entries: ParBuckets::from_slice(&self.entries),
411419
}
412420
}
413421

@@ -417,7 +425,7 @@ where
417425
/// in the slice is still preserved for operations like `reduce` and `collect`.
418426
pub fn par_values(&self) -> ParValues<'_, K, V> {
419427
ParValues {
420-
entries: ParBuckets::from_slices((&self.entries, &[])),
428+
entries: ParBuckets::from_slice(&self.entries),
421429
}
422430
}
423431
}
@@ -530,7 +538,7 @@ where
530538
/// in the slice is still preserved for operations like `reduce` and `collect`.
531539
pub fn par_values_mut(&mut self) -> ParValuesMut<'_, K, V> {
532540
ParValuesMut {
533-
entries: ParBucketsMut::from_mut_slices((&mut self.entries, &mut [])),
541+
entries: ParBucketsMut::from_mut_slice(&mut self.entries),
534542
}
535543
}
536544
}

src/rayon/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ where
9898

9999
fn into_par_iter(self) -> Self::Iter {
100100
ParIter {
101-
entries: ParBuckets::from_slices((&self.entries, &[])),
101+
entries: ParBuckets::from_slice(&self.entries),
102102
}
103103
}
104104
}

0 commit comments

Comments
 (0)