Skip to content

Commit 06d62d7

Browse files
committed
apply clippy lints
1 parent 1cb2c36 commit 06d62d7

16 files changed

+20
-35
lines changed

clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
msrv = "1.36.0"

src/adaptors/coalesce.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ impl<I: Iterator, F: CoalescePredicate<I::Item, T>, T> FusedIterator for Coalesc
8686
/// An iterator adaptor that may join together adjacent elements.
8787
///
8888
/// See [`.coalesce()`](crate::Itertools::coalesce) for more information.
89-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
9089
pub type Coalesce<I, F> = CoalesceBy<I, F, <I as Iterator>::Item>;
9190

9291
impl<F, Item, T> CoalescePredicate<Item, T> for F
@@ -113,7 +112,6 @@ where
113112
/// An iterator adaptor that removes repeated duplicates, determining equality using a comparison function.
114113
///
115114
/// See [`.dedup_by()`](crate::Itertools::dedup_by) or [`.dedup()`](crate::Itertools::dedup) for more information.
116-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
117115
pub type DedupBy<I, Pred> = CoalesceBy<I, DedupPred2CoalescePred<Pred>, <I as Iterator>::Item>;
118116

119117
#[derive(Clone)]
@@ -186,7 +184,6 @@ where
186184
///
187185
/// See [`.dedup_by_with_count()`](crate::Itertools::dedup_by_with_count) or
188186
/// [`.dedup_with_count()`](crate::Itertools::dedup_with_count) for more information.
189-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
190187
pub type DedupByWithCount<I, Pred> =
191188
CoalesceBy<I, DedupPredWithCount2CoalescePred<Pred>, (usize, <I as Iterator>::Item)>;
192189

src/adaptors/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,7 @@ impl<I, J> Iterator for Product<I, J>
327327
}
328328
Some(x) => x
329329
};
330-
match self.a_cur {
331-
None => None,
332-
Some(ref a) => {
333-
Some((a.clone(), elt_b))
334-
}
335-
}
330+
self.a_cur.as_ref().map(|a| (a.clone(), elt_b))
336331
}
337332

338333
fn size_hint(&self) -> (usize, Option<usize>) {
@@ -490,7 +485,6 @@ impl<T: PartialOrd> MergePredicate<T> for MergeLte {
490485
/// Iterator element type is `I::Item`.
491486
///
492487
/// See [`.merge()`](crate::Itertools::merge_by) for more information.
493-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
494488
pub type Merge<I, J> = MergeBy<I, J, MergeLte>;
495489

496490
/// Create an iterator that merges elements in `i` and `j`.
@@ -1033,7 +1027,7 @@ impl<I, F> Iterator for Positions<I, F>
10331027
type Item = usize;
10341028

10351029
fn next(&mut self) -> Option<Self::Item> {
1036-
while let Some(v) = self.iter.next() {
1030+
for v in self.iter.by_ref() {
10371031
let i = self.count;
10381032
self.count = i + 1;
10391033
if (self.f)(v) {

src/combinations_with_replacement.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ where
6464
// If this is the first iteration, return early
6565
if self.first {
6666
// In empty edge cases, stop iterating immediately
67-
return if self.indices.len() != 0 && !self.pool.get_next() {
67+
return if !(self.indices.is_empty() || self.pool.get_next()) {
6868
None
6969
// Otherwise, yield the initial state
7070
} else {

src/concat_impl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ pub fn concat<I>(iterable: I) -> I::Item
1818
where I: IntoIterator,
1919
I::Item: Extend<<<I as IntoIterator>::Item as IntoIterator>::Item> + IntoIterator + Default
2020
{
21-
iterable.into_iter().fold1(|mut a, b| { a.extend(b); a }).unwrap_or_else(<_>::default)
21+
#[allow(deprecated)] //TODO: once msrv hits 1.51. replace `fold1` with `reduce`
22+
iterable.into_iter().fold1(|mut a, b| { a.extend(b); a }).unwrap_or_default()
2223
}

src/duplicates_impl.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ mod private {
188188
/// An iterator adapter to filter for duplicate elements.
189189
///
190190
/// See [`.duplicates_by()`](crate::Itertools::duplicates_by) for more information.
191-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
192191
pub type DuplicatesBy<I, V, F> = private::DuplicatesBy<I, V, private::ByFn<F>>;
193192

194193
/// Create a new `DuplicatesBy` iterator.

src/flatten_ok.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ where
138138
T: IntoIterator,
139139
T::IntoIter: Clone,
140140
{
141-
#[inline]
142141
clone_fields!(iter, inner_front, inner_back);
143142
}
144143

src/groupbylazy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ trait KeyFunction<A> {
77
fn call_mut(&mut self, arg: A) -> Self::Key;
88
}
99

10-
impl<'a, A, K, F: ?Sized> KeyFunction<A> for F
10+
impl<A, K, F: ?Sized> KeyFunction<A> for F
1111
where F: FnMut(A) -> K
1212
{
1313
type Key = K;
@@ -37,7 +37,7 @@ impl ChunkIndex {
3737
}
3838
}
3939

40-
impl<'a, A> KeyFunction<A> for ChunkIndex {
40+
impl<A> KeyFunction<A> for ChunkIndex {
4141
type Key = usize;
4242
#[inline(always)]
4343
fn call_mut(&mut self, _arg: A) -> Self::Key {

src/grouping_map.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pub fn new<I, K, V>(iter: I) -> GroupingMap<I>
3939
/// `GroupingMapBy` is an intermediate struct for efficient group-and-fold operations.
4040
///
4141
/// See [`GroupingMap`] for more informations.
42-
#[must_use = "GroupingMapBy is lazy and do nothing unless consumed"]
4342
pub type GroupingMapBy<I, F> = GroupingMap<MapForGrouping<I, F>>;
4443

4544
/// `GroupingMap` is an intermediate struct for efficient group-and-fold operations.
@@ -290,7 +289,7 @@ impl<I, K, V> GroupingMap<I>
290289
where F: FnMut(&K, &V) -> CK,
291290
CK: Ord,
292291
{
293-
self.max_by(|key, v1, v2| f(key, &v1).cmp(&f(key, &v2)))
292+
self.max_by(|key, v1, v2| f(key, v1).cmp(&f(key, v2)))
294293
}
295294

296295
/// Groups elements from the `GroupingMap` source by key and finds the minimum of each group.
@@ -368,7 +367,7 @@ impl<I, K, V> GroupingMap<I>
368367
where F: FnMut(&K, &V) -> CK,
369368
CK: Ord,
370369
{
371-
self.min_by(|key, v1, v2| f(key, &v1).cmp(&f(key, &v2)))
370+
self.min_by(|key, v1, v2| f(key, v1).cmp(&f(key, v2)))
372371
}
373372

374373
/// Groups elements from the `GroupingMap` source by key and find the maximum and minimum of
@@ -481,7 +480,7 @@ impl<I, K, V> GroupingMap<I>
481480
where F: FnMut(&K, &V) -> CK,
482481
CK: Ord,
483482
{
484-
self.minmax_by(|key, v1, v2| f(key, &v1).cmp(&f(key, &v2)))
483+
self.minmax_by(|key, v1, v2| f(key, v1).cmp(&f(key, v2)))
485484
}
486485

487486
/// Groups elements from the `GroupingMap` source by key and sums them.

src/intersperse.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ impl<I, ElemF> Iterator for IntersperseWith<I, ElemF>
107107
self.iter.fold(accum,
108108
|accum, x| {
109109
let accum = f(accum, element.generate());
110-
let accum = f(accum, x);
111-
accum
110+
f(accum, x)
112111
})
113112
}
114113
}

0 commit comments

Comments
 (0)