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