23 lines
960 B
Text
23 lines
960 B
Text
![]() |
error: you are collecting an iterator to check its length
|
||
|
--> $DIR/needless_collect.rs:5:15
|
||
|
|
|
||
|
5 | let len = sample.iter().collect::<Vec<_>>().len();
|
||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `sample.iter().count()`
|
||
|
|
|
||
|
= note: `-D needless-collect` implied by `-D warnings`
|
||
|
|
||
|
error: you are collecting an iterator to check if it is empty
|
||
|
--> $DIR/needless_collect.rs:6:8
|
||
|
|
|
||
|
6 | if sample.iter().collect::<Vec<_>>().is_empty() {
|
||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `sample.iter().any(|_| true)`
|
||
|
|
||
|
error: you are collecting an iterator to check if contains an element
|
||
|
--> $DIR/needless_collect.rs:9:5
|
||
|
|
|
||
|
9 | sample.iter().cloned().collect::<Vec<_>>().contains(&1);
|
||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `sample.iter().cloned().any(|&x| x == 1)`
|
||
|
|
||
|
error: aborting due to 3 previous errors
|
||
|
|