= 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 |
-LL | sample.iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
+LL ~
+LL ~ sample.iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
|
error: avoid using `collect()` when not needed
|
help: take the original Iterator's count instead of collecting it and finding the length
|
-LL |
-LL | sample.iter().count();
+LL ~
+LL ~ sample.iter().count();
|
error: avoid using `collect()` when not needed
|
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();
+LL ~
+LL ~ sample.iter().next().is_none();
|
error: avoid using `collect()` when not needed
|
help: check if the original Iterator contains an element instead of collecting then checking
|
-LL |
-LL | sample.iter().any(|x| x == &5);
+LL ~
+LL ~ sample.iter().any(|x| x == &5);
|
error: avoid using `collect()` when not needed
|
help: check if the original Iterator contains an element instead of collecting then checking
|
-LL |
-LL | sample.into_iter().any(|x| x == a);
+LL ~
+LL ~ sample.into_iter().any(|x| x == a);
|
-error: aborting due to 5 previous errors
+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
+ |
+LL ~
+LL ~ string.split('/').count()
+ |
+
+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
+ |
+LL ~
+LL ~ sample.iter().count()
+ |
+
+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
+ |
+LL ~
+LL ~ sample.iter().count()
+ |
+
+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
+ |
+LL ~
+LL ~ sample.iter().count()
+ |
+
+error: aborting due to 9 previous errors