2020-07-23 16:15:16 +00:00
|
|
|
error: avoid using `collect()` when not needed
|
2020-08-03 04:46:18 +00:00
|
|
|
--> $DIR/needless_collect_indirect.rs:5:5
|
2020-07-23 16:15:16 +00:00
|
|
|
|
|
|
|
|
LL | / let indirect_iter = sample.iter().collect::<Vec<_>>();
|
2020-07-23 16:44:44 +00:00
|
|
|
LL | | indirect_iter.into_iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
|
2020-07-23 16:15:16 +00:00
|
|
|
| |____^
|
|
|
|
|
|
|
|
|
= note: `-D clippy::needless-collect` implied by `-D warnings`
|
|
|
|
help: Use the original Iterator instead of collecting it and then producing a new one
|
|
|
|
|
|
|
|
|
LL |
|
2020-07-23 16:44:44 +00:00
|
|
|
LL | sample.iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
|
2020-07-23 16:15:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: avoid using `collect()` when not needed
|
2020-08-03 04:46:18 +00:00
|
|
|
--> $DIR/needless_collect_indirect.rs:7:5
|
2020-07-23 16:15:16 +00:00
|
|
|
|
|
|
|
|
LL | / let indirect_len = sample.iter().collect::<VecDeque<_>>();
|
|
|
|
LL | | indirect_len.len();
|
|
|
|
| |____^
|
|
|
|
|
|
|
|
|
help: Take the original Iterator's count instead of collecting it and finding the length
|
|
|
|
|
|
|
|
|
LL |
|
|
|
|
LL | sample.iter().count();
|
|
|
|
|
|
|
|
|
|
|
|
|
error: avoid using `collect()` when not needed
|
2020-08-03 04:46:18 +00:00
|
|
|
--> $DIR/needless_collect_indirect.rs:9:5
|
2020-07-23 16:15:16 +00:00
|
|
|
|
|
|
|
|
LL | / let indirect_empty = sample.iter().collect::<VecDeque<_>>();
|
|
|
|
LL | | indirect_empty.is_empty();
|
|
|
|
| |____^
|
|
|
|
|
|
|
|
|
help: Check if the original Iterator has anything instead of collecting it and seeing if it's empty
|
|
|
|
|
|
|
|
|
LL |
|
|
|
|
LL | sample.iter().next().is_none();
|
|
|
|
|
|
|
|
|
|
|
|
|
error: avoid using `collect()` when not needed
|
2020-08-03 04:46:18 +00:00
|
|
|
--> $DIR/needless_collect_indirect.rs:11:5
|
2020-07-23 16:15:16 +00:00
|
|
|
|
|
|
|
|
LL | / let indirect_contains = sample.iter().collect::<VecDeque<_>>();
|
|
|
|
LL | | indirect_contains.contains(&&5);
|
|
|
|
| |____^
|
|
|
|
|
|
|
|
|
help: Check if the original Iterator contains an element instead of collecting then checking
|
|
|
|
|
|
|
|
|
LL |
|
2020-10-21 13:33:41 +00:00
|
|
|
LL | sample.iter().any(|x| x == &5);
|
2020-07-23 16:15:16 +00:00
|
|
|
|
|
|
|
|
|
2020-10-25 14:55:41 +00:00
|
|
|
error: avoid using `collect()` when not needed
|
|
|
|
--> $DIR/needless_collect_indirect.rs:23:5
|
|
|
|
|
|
|
|
|
LL | / let non_copy_contains = sample.into_iter().collect::<Vec<_>>();
|
|
|
|
LL | | non_copy_contains.contains(&a);
|
|
|
|
| |____^
|
|
|
|
|
|
|
|
|
help: Check if the original Iterator contains an element instead of collecting then checking
|
|
|
|
|
|
|
|
|
LL |
|
|
|
|
LL | sample.into_iter().any(|x| x == a);
|
|
|
|
|
|
|
|
|
|
|
|
|
error: aborting due to 5 previous errors
|
2020-07-23 16:15:16 +00:00
|
|
|
|