rust/tests/ui/needless_collect.stderr

29 lines
1.2 KiB
Plaintext
Raw Normal View History

error: you are collecting an iterator to check its length
2018-08-31 18:14:33 -04:00
--> $DIR/needless_collect.rs:7:28
|
2018-08-31 18:14:33 -04:00
7 | let len = sample.iter().collect::<Vec<_>>().len();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.count()`
|
= note: `-D needless-collect` implied by `-D warnings`
error: you are collecting an iterator to check if it is empty
2018-08-31 18:14:33 -04:00
--> $DIR/needless_collect.rs:8:21
|
2018-08-31 18:14:33 -04:00
8 | if sample.iter().collect::<Vec<_>>().is_empty() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.next().is_none()`
error: you are collecting an iterator to check if contains an element
2018-08-31 18:14:33 -04:00
--> $DIR/needless_collect.rs:11:27
|
11 | sample.iter().cloned().collect::<Vec<_>>().contains(&1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.any(|&x| x == 1)`
error: you are collecting an iterator to check its length
--> $DIR/needless_collect.rs:12:34
|
12 | sample.iter().map(|x| (x, x)).collect::<HashMap<_, _>>().len();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.count()`
2018-08-31 18:14:33 -04:00
error: aborting due to 4 previous errors