1
1
error: avoid using `collect()` when not needed
2
- --> $DIR/needless_collect_indirect.rs:5:5
2
+ --> $DIR/needless_collect_indirect.rs:5:39
3
3
|
4
- LL | / let indirect_iter = sample.iter().collect::<Vec<_>>();
5
- LL | | indirect_iter.into_iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
6
- | |____^
4
+ LL | let indirect_iter = sample.iter().collect::<Vec<_>>();
5
+ | ^^^^^^^
6
+ LL | indirect_iter.into_iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
7
+ | ------------------------- the iterator could be used here instead
7
8
|
8
9
= note: `-D clippy::needless-collect` implied by `-D warnings`
9
10
help: use the original Iterator instead of collecting it and then producing a new one
@@ -13,11 +14,12 @@ LL | sample.iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
13
14
|
14
15
15
16
error: avoid using `collect()` when not needed
16
- --> $DIR/needless_collect_indirect.rs:7:5
17
+ --> $DIR/needless_collect_indirect.rs:7:38
17
18
|
18
- LL | / let indirect_len = sample.iter().collect::<VecDeque<_>>();
19
- LL | | indirect_len.len();
20
- | |____^
19
+ LL | let indirect_len = sample.iter().collect::<VecDeque<_>>();
20
+ | ^^^^^^^
21
+ LL | indirect_len.len();
22
+ | ------------------ the iterator could be used here instead
21
23
|
22
24
help: take the original Iterator's count instead of collecting it and finding the length
23
25
|
@@ -26,11 +28,12 @@ LL | sample.iter().count();
26
28
|
27
29
28
30
error: avoid using `collect()` when not needed
29
- --> $DIR/needless_collect_indirect.rs:9:5
31
+ --> $DIR/needless_collect_indirect.rs:9:40
30
32
|
31
- LL | / let indirect_empty = sample.iter().collect::<VecDeque<_>>();
32
- LL | | indirect_empty.is_empty();
33
- | |____^
33
+ LL | let indirect_empty = sample.iter().collect::<VecDeque<_>>();
34
+ | ^^^^^^^
35
+ LL | indirect_empty.is_empty();
36
+ | ------------------------- the iterator could be used here instead
34
37
|
35
38
help: check if the original Iterator has anything instead of collecting it and seeing if it's empty
36
39
|
@@ -39,11 +42,12 @@ LL | sample.iter().next().is_none();
39
42
|
40
43
41
44
error: avoid using `collect()` when not needed
42
- --> $DIR/needless_collect_indirect.rs:11:5
45
+ --> $DIR/needless_collect_indirect.rs:11:43
43
46
|
44
- LL | / let indirect_contains = sample.iter().collect::<VecDeque<_>>();
45
- LL | | indirect_contains.contains(&&5);
46
- | |____^
47
+ LL | let indirect_contains = sample.iter().collect::<VecDeque<_>>();
48
+ | ^^^^^^^
49
+ LL | indirect_contains.contains(&&5);
50
+ | ------------------------------- the iterator could be used here instead
47
51
|
48
52
help: check if the original Iterator contains an element instead of collecting then checking
49
53
|
@@ -52,11 +56,12 @@ LL | sample.iter().any(|x| x == &5);
52
56
|
53
57
54
58
error: avoid using `collect()` when not needed
55
- --> $DIR/needless_collect_indirect.rs:23:5
59
+ --> $DIR/needless_collect_indirect.rs:23:48
56
60
|
57
- LL | / let non_copy_contains = sample.into_iter().collect::<Vec<_>>();
58
- LL | | non_copy_contains.contains(&a);
59
- | |____^
61
+ LL | let non_copy_contains = sample.into_iter().collect::<Vec<_>>();
62
+ | ^^^^^^^
63
+ LL | non_copy_contains.contains(&a);
64
+ | ------------------------------ the iterator could be used here instead
60
65
|
61
66
help: check if the original Iterator contains an element instead of collecting then checking
62
67
|
0 commit comments