about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/manual_find_fixable.stderr
blob: 0c05c0d2c4404a8bfe191be06f42ecede092093e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:10:5
   |
LL | /     for &v in ARRAY {
LL | |
LL | |         if v == n {
LL | |             return Some(v);
...  |
LL | |     None
   | |________^ help: replace with an iterator: `ARRAY.iter().find(|&&v| v == n).copied()`
   |
   = note: `-D clippy::manual-find` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::manual_find)]`

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:20:5
   |
LL | /     for (a, _) in arr {
LL | |
LL | |         if a.is_multiple_of(2) {
LL | |             return Some(a);
...  |
LL | |     None
   | |________^ help: replace with an iterator: `arr.into_iter().map(|(a, _)| a).find(|&a| a.is_multiple_of(2))`

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:34:5
   |
LL | /     for el in arr {
LL | |
LL | |         if el.name.len() == 10 {
LL | |             return Some(el);
...  |
LL | |     None
   | |________^ help: replace with an iterator: `arr.into_iter().find(|el| el.name.len() == 10)`
   |
   = note: you may need to dereference some variables

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:45:5
   |
LL | /     for Tuple(a, _) in arr {
LL | |
LL | |         if a >= 3 {
LL | |             return Some(a);
...  |
LL | |     None
   | |________^ help: replace with an iterator: `arr.into_iter().map(|Tuple(a, _)| a).find(|&a| a >= 3)`

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:61:5
   |
LL | /     for el in arr {
LL | |
LL | |         if el.should_keep() {
LL | |             return Some(el);
...  |
LL | |     None
   | |________^ help: replace with an iterator: `arr.into_iter().find(|el| el.should_keep())`
   |
   = note: you may need to dereference some variables

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:72:5
   |
LL | /     for el in arr {
LL | |
LL | |         if f(el) == 20 {
LL | |             return Some(el);
...  |
LL | |     None
   | |________^ help: replace with an iterator: `arr.into_iter().find(|&el| f(el) == 20)`

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:83:5
   |
LL | /     for &el in arr.values() {
LL | |
LL | |         if f(el) {
LL | |             return Some(el);
...  |
LL | |     None
   | |________^ help: replace with an iterator: `arr.values().find(|&&el| f(el)).copied()`

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:93:5
   |
LL | /     for el in arr {
LL | |
LL | |         if el.is_true {
LL | |             return Some(el);
...  |
LL | |     None
   | |________^ help: replace with an iterator: `arr.into_iter().find(|el| el.is_true)`
   |
   = note: you may need to dereference some variables

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:124:5
   |
LL | /     for (_, &x) in v {
LL | |
LL | |         if x > 10 {
LL | |             return Some(x);
...  |
LL | |     None
   | |________^ help: replace with an iterator: `v.into_iter().map(|(_, &x)| x).find(|&x| x > 10)`

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:134:5
   |
LL | /     for &(_, &x) in v {
LL | |
LL | |         if x > 10 {
LL | |             return Some(x);
...  |
LL | |     None
   | |________^ help: replace with an iterator: `v.iter().map(|&(_, &x)| x).find(|&x| x > 10)`

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:144:5
   |
LL | /     for x in arr {
LL | |
LL | |         if x >= 5 {
LL | |             return Some(x);
...  |
LL | |     return None;
   | |________________^ help: replace with an iterator: `arr.into_iter().find(|&x| x >= 5)`

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:200:9
   |
LL | /         for x in arr {
LL | |
LL | |             if x < 1 {
LL | |                 return Some(x);
...  |
LL | |         None
   | |____________^ help: replace with an iterator: `arr.into_iter().find(|&x| x < 1)`

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:257:9
   |
LL | /         for candidate in &["foo", "bar"] {
LL | |
LL | |             if candidate.eq_ignore_ascii_case(needle) {
LL | |                 return Some(candidate);
...  |
LL | |         None
   | |____________^ help: replace with an iterator: `["foo", "bar"].iter().find(|&candidate| candidate.eq_ignore_ascii_case(needle)).map(|v| v as _)`

error: manual implementation of `Iterator::find`
  --> tests/ui/manual_find_fixable.rs:267:9
   |
LL | /         for &candidate in &["foo", "bar"] {
LL | |
LL | |             if candidate.eq_ignore_ascii_case(needle) {
LL | |                 return Some(candidate);
...  |
LL | |         None
   | |____________^ help: replace with an iterator: `["foo", "bar"].iter().find(|&&candidate| candidate.eq_ignore_ascii_case(needle)).copied().map(|v| v as _)`

error: aborting due to 14 previous errors