Skip to content

Commit 5c11e00

Browse files
bors[bot]hellow554
andauthored
Merge #624
624: Hellow554 lints 1 r=phimuemue a=phimuemue First batch of #618. bors r+ Co-authored-by: Marcel Hellwig <[email protected]>
2 parents 28cff76 + aac4268 commit 5c11e00

File tree

12 files changed

+38
-43
lines changed

12 files changed

+38
-43
lines changed

src/concat_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ 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+
iterable.into_iter().fold1(|mut a, b| { a.extend(b); a }).unwrap_or_default()
2222
}

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl<I, K, V> GroupingMap<I>
289289
where F: FnMut(&K, &V) -> CK,
290290
CK: Ord,
291291
{
292-
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)))
293293
}
294294

295295
/// Groups elements from the `GroupingMap` source by key and finds the minimum of each group.
@@ -367,7 +367,7 @@ impl<I, K, V> GroupingMap<I>
367367
where F: FnMut(&K, &V) -> CK,
368368
CK: Ord,
369369
{
370-
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)))
371371
}
372372

373373
/// Groups elements from the `GroupingMap` source by key and find the maximum and minimum of
@@ -480,7 +480,7 @@ impl<I, K, V> GroupingMap<I>
480480
where F: FnMut(&K, &V) -> CK,
481481
CK: Ord,
482482
{
483-
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)))
484484
}
485485

486486
/// 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
}

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,7 @@ pub trait Itertools : Iterator {
17971797
Some(if predicate(&first) {
17981798
first
17991799
} else {
1800-
self.find(|x| predicate(&x)).unwrap_or(first)
1800+
self.find(|x| predicate(x)).unwrap_or(first)
18011801
})
18021802
}
18031803
/// Returns `true` if the given item is present in this iterator.
@@ -2694,7 +2694,6 @@ pub trait Itertools : Iterator {
26942694
/// itertools::assert_equal(oldest_people_first,
26952695
/// vec!["Jill", "Jack", "Jane", "John"]);
26962696
/// ```
2697-
/// ```
26982697
#[cfg(feature = "use_alloc")]
26992698
fn sorted_by_cached_key<K, F>(self, f: F) -> VecIntoIter<Self::Item>
27002699
where

src/multipeek_impl.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ impl<I> PeekingNext for MultiPeek<I>
7171
if let Some(r) = self.peek() {
7272
if !accept(r) { return None }
7373
}
74-
} else {
75-
if let Some(r) = self.buf.get(0) {
76-
if !accept(r) { return None }
77-
}
74+
} else if let Some(r) = self.buf.get(0) {
75+
if !accept(r) { return None }
7876
}
7977
self.next()
8078
}

src/ziptuple.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub struct Zip<T> {
3636
///
3737
/// assert_eq!(results, [0 + 3, 10 + 7, 29, 36]);
3838
/// ```
39+
/// [`izip!()`]: crate::izip
3940
pub fn multizip<T, U>(t: U) -> Zip<T>
4041
where Zip<T>: From<U>,
4142
Zip<T>: Iterator,

tests/quick.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,12 @@ where
258258
let mut it = get_it();
259259

260260
for _ in 0..(counts.len() - 1) {
261-
if let None = it.next() {
261+
if it.next().is_none() {
262262
panic!("Iterator shouldn't be finished, may not be deterministic");
263263
}
264264
}
265265

266-
if let None = it.next() {
266+
if it.next().is_none() {
267267
break 'outer;
268268
}
269269

@@ -721,7 +721,7 @@ quickcheck! {
721721

722722
assert_eq!(expected_first, curr_perm);
723723

724-
while let Some(next_perm) = perms.next() {
724+
for next_perm in perms {
725725
assert!(
726726
next_perm > curr_perm,
727727
"next perm isn't greater-than current; next_perm={:?} curr_perm={:?} n={}",
@@ -943,8 +943,7 @@ quickcheck! {
943943
fn fuzz_group_by_lazy_1(it: Iter<u8>) -> bool {
944944
let jt = it.clone();
945945
let groups = it.group_by(|k| *k);
946-
let res = itertools::equal(jt, groups.into_iter().flat_map(|(_, x)| x));
947-
res
946+
itertools::equal(jt, groups.into_iter().flat_map(|(_, x)| x))
948947
}
949948
}
950949

@@ -1286,7 +1285,7 @@ quickcheck! {
12861285
.map(|i| (i % modulo, i))
12871286
.into_group_map()
12881287
.into_iter()
1289-
.map(|(key, vals)| (key, vals.into_iter().fold(0u64, |acc, val| acc + val)))
1288+
.map(|(key, vals)| (key, vals.into_iter().sum()))
12901289
.collect::<HashMap<_,_>>();
12911290
assert_eq!(lookup, group_map_lookup);
12921291

@@ -1551,7 +1550,6 @@ quickcheck! {
15511550
}
15521551

15531552
quickcheck! {
1554-
#[test]
15551553
fn counts(nums: Vec<isize>) -> TestResult {
15561554
let counts = nums.iter().counts();
15571555
for (&item, &count) in counts.iter() {
@@ -1602,7 +1600,7 @@ quickcheck! {
16021600

16031601
fn is_fused<I: Iterator>(mut it: I) -> bool
16041602
{
1605-
while let Some(_) = it.next() {}
1603+
for _ in it.by_ref() {}
16061604
for _ in 0..10{
16071605
if it.next().is_some(){
16081606
return false;

tests/specializations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ quickcheck! {
129129
check_results_specialized!(it, |i| {
130130
let mut parameters_from_fold = vec![];
131131
let fold_result = i.fold(vec![], |mut acc, v| {
132-
parameters_from_fold.push((acc.clone(), v.clone()));
132+
parameters_from_fold.push((acc.clone(), v));
133133
acc.push(v);
134134
acc
135135
});
@@ -139,7 +139,7 @@ quickcheck! {
139139
let mut parameters_from_all = vec![];
140140
let first = i.next();
141141
let all_result = i.all(|x| {
142-
parameters_from_all.push(x.clone());
142+
parameters_from_all.push(x);
143143
Some(x)==first
144144
});
145145
(parameters_from_all, all_result)

tests/test_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn chain2() {
116116
fn write_to() {
117117
let xs = [7, 9, 8];
118118
let mut ys = [0; 5];
119-
let cnt = ys.iter_mut().set_from(xs.iter().map(|x| *x));
119+
let cnt = ys.iter_mut().set_from(xs.iter().copied());
120120
assert!(cnt == xs.len());
121121
assert!(ys == [7, 9, 8, 0, 0]);
122122

0 commit comments

Comments
 (0)