11error: avoid using `collect()` when not needed
2- --> $DIR/needless_collect_indirect.rs:5:5
2+ --> $DIR/needless_collect_indirect.rs:5:39
33 |
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
78 |
89 = note: `-D clippy::needless-collect` implied by `-D warnings`
910help: 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<_, _>>();
1314 |
1415
1516error: avoid using `collect()` when not needed
16- --> $DIR/needless_collect_indirect.rs:7:5
17+ --> $DIR/needless_collect_indirect.rs:7:38
1718 |
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
2123 |
2224help: take the original Iterator's count instead of collecting it and finding the length
2325 |
@@ -26,11 +28,12 @@ LL | sample.iter().count();
2628 |
2729
2830error: avoid using `collect()` when not needed
29- --> $DIR/needless_collect_indirect.rs:9:5
31+ --> $DIR/needless_collect_indirect.rs:9:40
3032 |
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
3437 |
3538help: check if the original Iterator has anything instead of collecting it and seeing if it's empty
3639 |
@@ -39,11 +42,12 @@ LL | sample.iter().next().is_none();
3942 |
4043
4144error: avoid using `collect()` when not needed
42- --> $DIR/needless_collect_indirect.rs:11:5
45+ --> $DIR/needless_collect_indirect.rs:11:43
4346 |
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
4751 |
4852help: check if the original Iterator contains an element instead of collecting then checking
4953 |
@@ -52,11 +56,12 @@ LL | sample.iter().any(|x| x == &5);
5256 |
5357
5458error: avoid using `collect()` when not needed
55- --> $DIR/needless_collect_indirect.rs:23:5
59+ --> $DIR/needless_collect_indirect.rs:23:48
5660 |
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
6065 |
6166help: check if the original Iterator contains an element instead of collecting then checking
6267 |
0 commit comments