1
1
error: use Option::map_or instead of an if let/else
2
- --> $DIR/option_if_let_else.rs:12 :5
2
+ --> $DIR/option_if_let_else.rs:11 :5
3
3
|
4
4
LL | / if let Some(x) = string {
5
5
LL | | (true, x)
@@ -12,19 +12,19 @@ LL | | }
12
12
= help: to override `-D warnings` add `#[allow(clippy::option_if_let_else)]`
13
13
14
14
error: use Option::map_or instead of an if let/else
15
- --> $DIR/option_if_let_else.rs:30 :13
15
+ --> $DIR/option_if_let_else.rs:29 :13
16
16
|
17
17
LL | let _ = if let Some(s) = *string { s.len() } else { 0 };
18
18
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())`
19
19
20
20
error: use Option::map_or instead of an if let/else
21
- --> $DIR/option_if_let_else.rs:31 :13
21
+ --> $DIR/option_if_let_else.rs:30 :13
22
22
|
23
23
LL | let _ = if let Some(s) = &num { s } else { &0 };
24
24
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
25
25
26
26
error: use Option::map_or instead of an if let/else
27
- --> $DIR/option_if_let_else.rs:32 :13
27
+ --> $DIR/option_if_let_else.rs:31 :13
28
28
|
29
29
LL | let _ = if let Some(s) = &mut num {
30
30
| _____________^
@@ -44,13 +44,13 @@ LL ~ });
44
44
|
45
45
46
46
error: use Option::map_or instead of an if let/else
47
- --> $DIR/option_if_let_else.rs:38 :13
47
+ --> $DIR/option_if_let_else.rs:37 :13
48
48
|
49
49
LL | let _ = if let Some(ref s) = num { s } else { &0 };
50
50
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
51
51
52
52
error: use Option::map_or instead of an if let/else
53
- --> $DIR/option_if_let_else.rs:39 :13
53
+ --> $DIR/option_if_let_else.rs:38 :13
54
54
|
55
55
LL | let _ = if let Some(mut s) = num {
56
56
| _____________^
@@ -70,7 +70,7 @@ LL ~ });
70
70
|
71
71
72
72
error: use Option::map_or instead of an if let/else
73
- --> $DIR/option_if_let_else.rs:45 :13
73
+ --> $DIR/option_if_let_else.rs:44 :13
74
74
|
75
75
LL | let _ = if let Some(ref mut s) = num {
76
76
| _____________^
@@ -90,7 +90,7 @@ LL ~ });
90
90
|
91
91
92
92
error: use Option::map_or instead of an if let/else
93
- --> $DIR/option_if_let_else.rs:54 :5
93
+ --> $DIR/option_if_let_else.rs:53 :5
94
94
|
95
95
LL | / if let Some(x) = arg {
96
96
LL | | let y = x * x;
@@ -109,7 +109,7 @@ LL + })
109
109
|
110
110
111
111
error: use Option::map_or_else instead of an if let/else
112
- --> $DIR/option_if_let_else.rs:67 :13
112
+ --> $DIR/option_if_let_else.rs:66 :13
113
113
|
114
114
LL | let _ = if let Some(x) = arg {
115
115
| _____________^
@@ -118,10 +118,10 @@ LL | | } else {
118
118
LL | | // map_or_else must be suggested
119
119
LL | | side_effect()
120
120
LL | | };
121
- | |_____^ help: try: `arg.map_or_else(|| side_effect() , |x| x)`
121
+ | |_____^ help: try: `arg.map_or_else(side_effect, |x| x)`
122
122
123
123
error: use Option::map_or_else instead of an if let/else
124
- --> $DIR/option_if_let_else.rs:76 :13
124
+ --> $DIR/option_if_let_else.rs:75 :13
125
125
|
126
126
LL | let _ = if let Some(x) = arg {
127
127
| _____________^
@@ -144,7 +144,7 @@ LL ~ }, |x| x * x * x * x);
144
144
|
145
145
146
146
error: use Option::map_or_else instead of an if let/else
147
- --> $DIR/option_if_let_else.rs:109 :13
147
+ --> $DIR/option_if_let_else.rs:108 :13
148
148
|
149
149
LL | / if let Some(idx) = s.find('.') {
150
150
LL | | vec![s[..idx].to_string(), s[idx..].to_string()]
@@ -154,7 +154,7 @@ LL | | }
154
154
| |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])`
155
155
156
156
error: use Option::map_or_else instead of an if let/else
157
- --> $DIR/option_if_let_else.rs:120 :5
157
+ --> $DIR/option_if_let_else.rs:119 :5
158
158
|
159
159
LL | / if let Ok(binding) = variable {
160
160
LL | | println!("Ok {binding}");
@@ -173,13 +173,13 @@ LL + })
173
173
|
174
174
175
175
error: use Option::map_or instead of an if let/else
176
- --> $DIR/option_if_let_else.rs:142 :13
176
+ --> $DIR/option_if_let_else.rs:141 :13
177
177
|
178
178
LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
179
179
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
180
180
181
181
error: use Option::map_or instead of an if let/else
182
- --> $DIR/option_if_let_else.rs:152 :13
182
+ --> $DIR/option_if_let_else.rs:151 :13
183
183
|
184
184
LL | let _ = if let Some(x) = Some(0) {
185
185
| _____________^
@@ -201,13 +201,13 @@ LL ~ });
201
201
|
202
202
203
203
error: use Option::map_or instead of an if let/else
204
- --> $DIR/option_if_let_else.rs:180 :13
204
+ --> $DIR/option_if_let_else.rs:179 :13
205
205
|
206
206
LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() };
207
207
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)`
208
208
209
209
error: use Option::map_or instead of an if let/else
210
- --> $DIR/option_if_let_else.rs:184 :13
210
+ --> $DIR/option_if_let_else.rs:183 :13
211
211
|
212
212
LL | let _ = if let Some(x) = Some(0) {
213
213
| _____________^
@@ -227,7 +227,7 @@ LL ~ });
227
227
|
228
228
229
229
error: use Option::map_or instead of an if let/else
230
- --> $DIR/option_if_let_else.rs:223 :13
230
+ --> $DIR/option_if_let_else.rs:222 :13
231
231
|
232
232
LL | let _ = match s {
233
233
| _____________^
@@ -237,7 +237,7 @@ LL | | };
237
237
| |_____^ help: try: `s.map_or(1, |string| string.len())`
238
238
239
239
error: use Option::map_or instead of an if let/else
240
- --> $DIR/option_if_let_else.rs:227 :13
240
+ --> $DIR/option_if_let_else.rs:226 :13
241
241
|
242
242
LL | let _ = match Some(10) {
243
243
| _____________^
@@ -247,7 +247,7 @@ LL | | };
247
247
| |_____^ help: try: `Some(10).map_or(5, |a| a + 1)`
248
248
249
249
error: use Option::map_or instead of an if let/else
250
- --> $DIR/option_if_let_else.rs:233 :13
250
+ --> $DIR/option_if_let_else.rs:232 :13
251
251
|
252
252
LL | let _ = match res {
253
253
| _____________^
@@ -257,7 +257,7 @@ LL | | };
257
257
| |_____^ help: try: `res.map_or(1, |a| a + 1)`
258
258
259
259
error: use Option::map_or instead of an if let/else
260
- --> $DIR/option_if_let_else.rs:237 :13
260
+ --> $DIR/option_if_let_else.rs:236 :13
261
261
|
262
262
LL | let _ = match res {
263
263
| _____________^
@@ -267,13 +267,13 @@ LL | | };
267
267
| |_____^ help: try: `res.map_or(1, |a| a + 1)`
268
268
269
269
error: use Option::map_or instead of an if let/else
270
- --> $DIR/option_if_let_else.rs:241 :13
270
+ --> $DIR/option_if_let_else.rs:240 :13
271
271
|
272
272
LL | let _ = if let Ok(a) = res { a + 1 } else { 5 };
273
273
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)`
274
274
275
275
error: use Option::map_or instead of an if let/else
276
- --> $DIR/option_if_let_else.rs:258 :9
276
+ --> $DIR/option_if_let_else.rs:257 :9
277
277
|
278
278
LL | / match initial {
279
279
LL | | Some(value) => do_something(value),
@@ -282,13 +282,30 @@ LL | | }
282
282
| |_________^ help: try: `initial.as_ref().map_or({}, |value| do_something(value))`
283
283
284
284
error: use Option::map_or instead of an if let/else
285
- --> $DIR/option_if_let_else.rs:265 :9
285
+ --> $DIR/option_if_let_else.rs:264 :9
286
286
|
287
287
LL | / match initial {
288
288
LL | | Some(value) => do_something2(value),
289
289
LL | | None => {},
290
290
LL | | }
291
291
| |_________^ help: try: `initial.as_mut().map_or({}, |value| do_something2(value))`
292
292
293
- error: aborting due to 23 previous errors
293
+ error: use Option::map_or_else instead of an if let/else
294
+ --> $DIR/option_if_let_else.rs:283:24
295
+ |
296
+ LL | let mut _hashmap = if let Some(hm) = &opt {
297
+ | ________________________^
298
+ LL | | hm.clone()
299
+ LL | | } else {
300
+ LL | | HashMap::new()
301
+ LL | | };
302
+ | |_____^ help: try: `opt.as_ref().map_or_else(HashMap::new, |hm| hm.clone())`
303
+
304
+ error: use Option::map_or_else instead of an if let/else
305
+ --> $DIR/option_if_let_else.rs:289:19
306
+ |
307
+ LL | let mut _hm = if let Some(hm) = &opt { hm.clone() } else { new_map!() };
308
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.as_ref().map_or_else(|| new_map!(), |hm| hm.clone())`
309
+
310
+ error: aborting due to 25 previous errors
294
311
0 commit comments