2020-08-11 13:43:21 +00:00
|
|
|
error: avoid using `collect()` when not needed
|
2021-04-08 15:50:13 +00:00
|
|
|
--> $DIR/needless_collect_indirect.rs:5:39
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2021-04-08 15:50:13 +00:00
|
|
|
LL | let indirect_iter = sample.iter().collect::<Vec<_>>();
|
|
|
|
| ^^^^^^^
|
|
|
|
LL | indirect_iter.into_iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
|
|
|
|
| ------------------------- the iterator could be used here instead
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
|
|
|
= note: `-D clippy::needless-collect` implied by `-D warnings`
|
2021-03-12 14:30:50 +00:00
|
|
|
help: use the original Iterator instead of collecting it and then producing a new one
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ sample.iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: avoid using `collect()` when not needed
|
2021-04-08 15:50:13 +00:00
|
|
|
--> $DIR/needless_collect_indirect.rs:7:38
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2021-04-08 15:50:13 +00:00
|
|
|
LL | let indirect_len = sample.iter().collect::<VecDeque<_>>();
|
|
|
|
| ^^^^^^^
|
|
|
|
LL | indirect_len.len();
|
|
|
|
| ------------------ the iterator could be used here instead
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2021-03-12 14:30:50 +00:00
|
|
|
help: take the original Iterator's count instead of collecting it and finding the length
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ sample.iter().count();
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: avoid using `collect()` when not needed
|
2021-04-08 15:50:13 +00:00
|
|
|
--> $DIR/needless_collect_indirect.rs:9:40
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2021-04-08 15:50:13 +00:00
|
|
|
LL | let indirect_empty = sample.iter().collect::<VecDeque<_>>();
|
|
|
|
| ^^^^^^^
|
|
|
|
LL | indirect_empty.is_empty();
|
|
|
|
| ------------------------- the iterator could be used here instead
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2021-03-12 14:30:50 +00:00
|
|
|
help: check if the original Iterator has anything instead of collecting it and seeing if it's empty
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ sample.iter().next().is_none();
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: avoid using `collect()` when not needed
|
2021-04-08 15:50:13 +00:00
|
|
|
--> $DIR/needless_collect_indirect.rs:11:43
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2021-04-08 15:50:13 +00:00
|
|
|
LL | let indirect_contains = sample.iter().collect::<VecDeque<_>>();
|
|
|
|
| ^^^^^^^
|
|
|
|
LL | indirect_contains.contains(&&5);
|
|
|
|
| ------------------------------- the iterator could be used here instead
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2021-03-12 14:30:50 +00:00
|
|
|
help: check if the original Iterator contains an element instead of collecting then checking
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ sample.iter().any(|x| x == &5);
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
|
|
|
|
2020-10-28 22:36:07 +00:00
|
|
|
error: avoid using `collect()` when not needed
|
2021-04-08 15:50:13 +00:00
|
|
|
--> $DIR/needless_collect_indirect.rs:23:48
|
2020-10-28 22:36:07 +00:00
|
|
|
|
|
2021-04-08 15:50:13 +00:00
|
|
|
LL | let non_copy_contains = sample.into_iter().collect::<Vec<_>>();
|
|
|
|
| ^^^^^^^
|
|
|
|
LL | non_copy_contains.contains(&a);
|
|
|
|
| ------------------------------ the iterator could be used here instead
|
2020-10-28 22:36:07 +00:00
|
|
|
|
|
2021-03-12 14:30:50 +00:00
|
|
|
help: check if the original Iterator contains an element instead of collecting then checking
|
2020-10-28 22:36:07 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ sample.into_iter().any(|x| x == a);
|
2020-10-28 22:36:07 +00:00
|
|
|
|
|
|
|
|
|
2021-05-06 09:51:22 +00:00
|
|
|
error: avoid using `collect()` when not needed
|
|
|
|
--> $DIR/needless_collect_indirect.rs:52:51
|
|
|
|
|
|
|
|
|
LL | let buffer: Vec<&str> = string.split('/').collect();
|
|
|
|
| ^^^^^^^
|
|
|
|
LL | buffer.len()
|
|
|
|
| ------------ the iterator could be used here instead
|
|
|
|
|
|
|
|
|
help: take the original Iterator's count instead of collecting it and finding the length
|
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ string.split('/').count()
|
2021-05-06 09:51:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: avoid using `collect()` when not needed
|
|
|
|
--> $DIR/needless_collect_indirect.rs:57:55
|
|
|
|
|
|
|
|
|
LL | let indirect_len: VecDeque<_> = sample.iter().collect();
|
|
|
|
| ^^^^^^^
|
|
|
|
LL | indirect_len.len()
|
|
|
|
| ------------------ the iterator could be used here instead
|
|
|
|
|
|
|
|
|
help: take the original Iterator's count instead of collecting it and finding the length
|
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ sample.iter().count()
|
2021-05-06 09:51:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: avoid using `collect()` when not needed
|
|
|
|
--> $DIR/needless_collect_indirect.rs:62:57
|
|
|
|
|
|
|
|
|
LL | let indirect_len: LinkedList<_> = sample.iter().collect();
|
|
|
|
| ^^^^^^^
|
|
|
|
LL | indirect_len.len()
|
|
|
|
| ------------------ the iterator could be used here instead
|
|
|
|
|
|
|
|
|
help: take the original Iterator's count instead of collecting it and finding the length
|
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ sample.iter().count()
|
2021-05-06 09:51:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: avoid using `collect()` when not needed
|
|
|
|
--> $DIR/needless_collect_indirect.rs:67:57
|
|
|
|
|
|
|
|
|
LL | let indirect_len: BinaryHeap<_> = sample.iter().collect();
|
|
|
|
| ^^^^^^^
|
|
|
|
LL | indirect_len.len()
|
|
|
|
| ------------------ the iterator could be used here instead
|
|
|
|
|
|
|
|
|
help: take the original Iterator's count instead of collecting it and finding the length
|
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ sample.iter().count()
|
2021-05-06 09:51:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: aborting due to 9 previous errors
|
2020-08-11 13:43:21 +00:00
|
|
|
|