@@ -158,28 +158,32 @@ error: use Option::map_or_else instead of an if let/else
158
158
|
159
159
LL | / if let Ok(binding) = variable {
160
160
LL | | println!("Ok {binding}");
161
+ LL | | true
161
162
LL | | } else {
162
163
LL | | println!("Err");
164
+ LL | | false
163
165
LL | | }
164
166
| |_____^
165
167
|
166
168
help: try
167
169
|
168
170
LL ~ variable.map_or_else(|_| {
169
171
LL + println!("Err");
172
+ LL + false
170
173
LL + }, |binding| {
171
174
LL + println!("Ok {binding}");
175
+ LL + true
172
176
LL + })
173
177
|
174
178
175
179
error: use Option::map_or instead of an if let/else
176
- --> $DIR/option_if_let_else.rs:141 :13
180
+ --> $DIR/option_if_let_else.rs:143 :13
177
181
|
178
182
LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
179
183
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
180
184
181
185
error: use Option::map_or instead of an if let/else
182
- --> $DIR/option_if_let_else.rs:151 :13
186
+ --> $DIR/option_if_let_else.rs:153 :13
183
187
|
184
188
LL | let _ = if let Some(x) = Some(0) {
185
189
| _____________^
@@ -201,13 +205,13 @@ LL ~ });
201
205
|
202
206
203
207
error: use Option::map_or instead of an if let/else
204
- --> $DIR/option_if_let_else.rs:179 :13
208
+ --> $DIR/option_if_let_else.rs:181 :13
205
209
|
206
210
LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() };
207
211
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)`
208
212
209
213
error: use Option::map_or instead of an if let/else
210
- --> $DIR/option_if_let_else.rs:183 :13
214
+ --> $DIR/option_if_let_else.rs:185 :13
211
215
|
212
216
LL | let _ = if let Some(x) = Some(0) {
213
217
| _____________^
@@ -227,7 +231,7 @@ LL ~ });
227
231
|
228
232
229
233
error: use Option::map_or instead of an if let/else
230
- --> $DIR/option_if_let_else.rs:222 :13
234
+ --> $DIR/option_if_let_else.rs:224 :13
231
235
|
232
236
LL | let _ = match s {
233
237
| _____________^
@@ -237,7 +241,7 @@ LL | | };
237
241
| |_____^ help: try: `s.map_or(1, |string| string.len())`
238
242
239
243
error: use Option::map_or instead of an if let/else
240
- --> $DIR/option_if_let_else.rs:226 :13
244
+ --> $DIR/option_if_let_else.rs:228 :13
241
245
|
242
246
LL | let _ = match Some(10) {
243
247
| _____________^
@@ -247,7 +251,7 @@ LL | | };
247
251
| |_____^ help: try: `Some(10).map_or(5, |a| a + 1)`
248
252
249
253
error: use Option::map_or instead of an if let/else
250
- --> $DIR/option_if_let_else.rs:232 :13
254
+ --> $DIR/option_if_let_else.rs:234 :13
251
255
|
252
256
LL | let _ = match res {
253
257
| _____________^
@@ -257,7 +261,7 @@ LL | | };
257
261
| |_____^ help: try: `res.map_or(1, |a| a + 1)`
258
262
259
263
error: use Option::map_or instead of an if let/else
260
- --> $DIR/option_if_let_else.rs:236 :13
264
+ --> $DIR/option_if_let_else.rs:238 :13
261
265
|
262
266
LL | let _ = match res {
263
267
| _____________^
@@ -267,31 +271,33 @@ LL | | };
267
271
| |_____^ help: try: `res.map_or(1, |a| a + 1)`
268
272
269
273
error: use Option::map_or instead of an if let/else
270
- --> $DIR/option_if_let_else.rs:240 :13
274
+ --> $DIR/option_if_let_else.rs:242 :13
271
275
|
272
276
LL | let _ = if let Ok(a) = res { a + 1 } else { 5 };
273
277
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)`
274
278
275
279
error: use Option::map_or instead of an if let/else
276
- --> $DIR/option_if_let_else.rs:257:9
280
+ --> $DIR/option_if_let_else.rs:259:17
277
281
|
278
- LL | / match initial {
282
+ LL | let _ = match initial {
283
+ | _________________^
279
284
LL | | Some(value) => do_something(value),
280
- LL | | None => {} ,
281
- LL | | }
282
- | |_________^ help: try: `initial.as_ref().map_or({} , |value| do_something(value))`
285
+ LL | | None => 42 ,
286
+ LL | | };
287
+ | |_________^ help: try: `initial.as_ref().map_or(42 , |value| do_something(value))`
283
288
284
289
error: use Option::map_or instead of an if let/else
285
- --> $DIR/option_if_let_else.rs:264:9
290
+ --> $DIR/option_if_let_else.rs:266:17
286
291
|
287
- LL | / match initial {
292
+ LL | let _ = match initial {
293
+ | _________________^
288
294
LL | | Some(value) => do_something2(value),
289
- LL | | None => {} ,
290
- LL | | }
291
- | |_________^ help: try: `initial.as_mut().map_or({} , |value| do_something2(value))`
295
+ LL | | None => 42 ,
296
+ LL | | };
297
+ | |_________^ help: try: `initial.as_mut().map_or(42 , |value| do_something2(value))`
292
298
293
299
error: use Option::map_or_else instead of an if let/else
294
- --> $DIR/option_if_let_else.rs:283 :24
300
+ --> $DIR/option_if_let_else.rs:289 :24
295
301
|
296
302
LL | let mut _hashmap = if let Some(hm) = &opt {
297
303
| ________________________^
@@ -302,7 +308,7 @@ LL | | };
302
308
| |_____^ help: try: `opt.as_ref().map_or_else(HashMap::new, |hm| hm.clone())`
303
309
304
310
error: use Option::map_or_else instead of an if let/else
305
- --> $DIR/option_if_let_else.rs:289 :19
311
+ --> $DIR/option_if_let_else.rs:295 :19
306
312
|
307
313
LL | let mut _hm = if let Some(hm) = &opt { hm.clone() } else { new_map!() };
308
314
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.as_ref().map_or_else(|| new_map!(), |hm| hm.clone())`
0 commit comments