Apply applicability
This commit is contained in:
parent
dfed9751bd
commit
061b2f3057
2 changed files with 41 additions and 35 deletions
|
|
@ -1,28 +1,28 @@
|
|||
error: you are collecting an iterator to check its length
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect.rs:7:28
|
||||
|
|
||||
7 | let len = sample.iter().collect::<Vec<_>>().len();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.count()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.count()`
|
||||
|
|
||||
= note: `-D needless-collect` implied by `-D warnings`
|
||||
|
||||
error: you are collecting an iterator to check if it is empty
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect.rs:8:21
|
||||
|
|
||||
8 | if sample.iter().collect::<Vec<_>>().is_empty() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.next().is_none()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.next().is_none()`
|
||||
|
||||
error: you are collecting an iterator to check if contains an element
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect.rs:11:27
|
||||
|
|
||||
11 | sample.iter().cloned().collect::<Vec<_>>().contains(&1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.any(|&x| x == 1)`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.any(|&x| x == 1)`
|
||||
|
||||
error: you are collecting an iterator to check its length
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect.rs:12:34
|
||||
|
|
||||
12 | sample.iter().map(|x| (x, x)).collect::<HashMap<_, _>>().len();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.count()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.count()`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue