]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/needless_collect_indirect.stderr
Merge branch 'master' into hooks
[rust.git] / src / tools / clippy / tests / ui / needless_collect_indirect.stderr
1 error: avoid using `collect()` when not needed
2   --> $DIR/needless_collect_indirect.rs:5:5
3    |
4 LL | /     let indirect_iter = sample.iter().collect::<Vec<_>>();
5 LL | |     indirect_iter.into_iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
6    | |____^
7    |
8    = note: `-D clippy::needless-collect` implied by `-D warnings`
9 help: Use the original Iterator instead of collecting it and then producing a new one
10    |
11 LL |     
12 LL |     sample.iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
13    |
14
15 error: avoid using `collect()` when not needed
16   --> $DIR/needless_collect_indirect.rs:7:5
17    |
18 LL | /     let indirect_len = sample.iter().collect::<VecDeque<_>>();
19 LL | |     indirect_len.len();
20    | |____^
21    |
22 help: Take the original Iterator's count instead of collecting it and finding the length
23    |
24 LL |     
25 LL |     sample.iter().count();
26    |
27
28 error: avoid using `collect()` when not needed
29   --> $DIR/needless_collect_indirect.rs:9:5
30    |
31 LL | /     let indirect_empty = sample.iter().collect::<VecDeque<_>>();
32 LL | |     indirect_empty.is_empty();
33    | |____^
34    |
35 help: Check if the original Iterator has anything instead of collecting it and seeing if it's empty
36    |
37 LL |     
38 LL |     sample.iter().next().is_none();
39    |
40
41 error: avoid using `collect()` when not needed
42   --> $DIR/needless_collect_indirect.rs:11:5
43    |
44 LL | /     let indirect_contains = sample.iter().collect::<VecDeque<_>>();
45 LL | |     indirect_contains.contains(&&5);
46    | |____^
47    |
48 help: Check if the original Iterator contains an element instead of collecting then checking
49    |
50 LL |     
51 LL |     sample.iter().any(|x| x == &&5);
52    |
53
54 error: aborting due to 4 previous errors
55