@@ -89,9 +89,17 @@ LL | | .unwrap_or(None);
89
89
|
90
90
= note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
91
91
92
- error: called `map(f).unwrap_or_else(g )` on an Option value. This can be done more directly by calling `map_or_else(g , f)` instead
92
+ error: called `map(f).unwrap_or(a )` on an Option value. This can be done more directly by calling `map_or(a , f)` instead
93
93
--> $DIR/methods.rs:187:13
94
94
|
95
+ LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
96
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97
+ |
98
+ = note: replace `map(|p| format!("{}.", p)).unwrap_or(id)` with `map_or(id, |p| format!("{}.", p))`
99
+
100
+ error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
101
+ --> $DIR/methods.rs:191:13
102
+ |
95
103
LL | let _ = opt.map(|x| x + 1)
96
104
| _____________^
97
105
LL | |
@@ -102,7 +110,7 @@ LL | | .unwrap_or_else(|| 0); // should lint even though this cal
102
110
= note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
103
111
104
112
error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
105
- --> $DIR/methods.rs:191 :13
113
+ --> $DIR/methods.rs:195 :13
106
114
|
107
115
LL | let _ = opt.map(|x| {
108
116
| _____________^
@@ -112,7 +120,7 @@ LL | | ).unwrap_or_else(|| 0);
112
120
| |____________________________________^
113
121
114
122
error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead
115
- --> $DIR/methods.rs:195 :13
123
+ --> $DIR/methods.rs:199 :13
116
124
|
117
125
LL | let _ = opt.map(|x| x + 1)
118
126
| _____________^
@@ -122,15 +130,15 @@ LL | | );
122
130
| |_________________^
123
131
124
132
error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
125
- --> $DIR/methods.rs:204 :13
133
+ --> $DIR/methods.rs:208 :13
126
134
|
127
135
LL | let _ = opt.map_or(None, |x| Some(x + 1));
128
136
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))`
129
137
|
130
138
= note: `-D clippy::option-map-or-none` implied by `-D warnings`
131
139
132
140
error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
133
- --> $DIR/methods.rs:206 :13
141
+ --> $DIR/methods.rs:210 :13
134
142
|
135
143
LL | let _ = opt.map_or(None, |x| {
136
144
| _____________^
@@ -146,7 +154,7 @@ LL | });
146
154
|
147
155
148
156
error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
149
- --> $DIR/methods.rs:232 :13
157
+ --> $DIR/methods.rs:236 :13
150
158
|
151
159
LL | let _ = v.iter().filter(|&x| *x < 0).next();
152
160
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -155,7 +163,7 @@ LL | let _ = v.iter().filter(|&x| *x < 0).next();
155
163
= note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
156
164
157
165
error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
158
- --> $DIR/methods.rs:235 :13
166
+ --> $DIR/methods.rs:239 :13
159
167
|
160
168
LL | let _ = v.iter().filter(|&x| {
161
169
| _____________^
@@ -165,7 +173,7 @@ LL | | ).next();
165
173
| |___________________________^
166
174
167
175
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
168
- --> $DIR/methods.rs:251 :13
176
+ --> $DIR/methods.rs:255 :13
169
177
|
170
178
LL | let _ = v.iter().find(|&x| *x < 0).is_some();
171
179
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -174,7 +182,7 @@ LL | let _ = v.iter().find(|&x| *x < 0).is_some();
174
182
= note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)`
175
183
176
184
error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
177
- --> $DIR/methods.rs:254 :13
185
+ --> $DIR/methods.rs:258 :13
178
186
|
179
187
LL | let _ = v.iter().find(|&x| {
180
188
| _____________^
@@ -184,15 +192,15 @@ LL | | ).is_some();
184
192
| |______________________________^
185
193
186
194
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
187
- --> $DIR/methods.rs:260 :13
195
+ --> $DIR/methods.rs:264 :13
188
196
|
189
197
LL | let _ = v.iter().position(|&x| x < 0).is_some();
190
198
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
191
199
|
192
200
= note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
193
201
194
202
error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
195
- --> $DIR/methods.rs:263 :13
203
+ --> $DIR/methods.rs:267 :13
196
204
|
197
205
LL | let _ = v.iter().position(|&x| {
198
206
| _____________^
@@ -202,15 +210,15 @@ LL | | ).is_some();
202
210
| |______________________________^
203
211
204
212
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
205
- --> $DIR/methods.rs:269 :13
213
+ --> $DIR/methods.rs:273 :13
206
214
|
207
215
LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
208
216
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
209
217
|
210
218
= note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
211
219
212
220
error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
213
- --> $DIR/methods.rs:272 :13
221
+ --> $DIR/methods.rs:276 :13
214
222
|
215
223
LL | let _ = v.iter().rposition(|&x| {
216
224
| _____________^
@@ -220,130 +228,130 @@ LL | | ).is_some();
220
228
| |______________________________^
221
229
222
230
error: use of `unwrap_or` followed by a function call
223
- --> $DIR/methods.rs:309 :22
231
+ --> $DIR/methods.rs:313 :22
224
232
|
225
233
LL | with_constructor.unwrap_or(make());
226
234
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
227
235
|
228
236
= note: `-D clippy::or-fun-call` implied by `-D warnings`
229
237
230
238
error: use of `unwrap_or` followed by a call to `new`
231
- --> $DIR/methods.rs:312 :5
239
+ --> $DIR/methods.rs:316 :5
232
240
|
233
241
LL | with_new.unwrap_or(Vec::new());
234
242
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`
235
243
236
244
error: use of `unwrap_or` followed by a function call
237
- --> $DIR/methods.rs:315 :21
245
+ --> $DIR/methods.rs:319 :21
238
246
|
239
247
LL | with_const_args.unwrap_or(Vec::with_capacity(12));
240
248
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
241
249
242
250
error: use of `unwrap_or` followed by a function call
243
- --> $DIR/methods.rs:318 :14
251
+ --> $DIR/methods.rs:322 :14
244
252
|
245
253
LL | with_err.unwrap_or(make());
246
254
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
247
255
248
256
error: use of `unwrap_or` followed by a function call
249
- --> $DIR/methods.rs:321 :19
257
+ --> $DIR/methods.rs:325 :19
250
258
|
251
259
LL | with_err_args.unwrap_or(Vec::with_capacity(12));
252
260
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
253
261
254
262
error: use of `unwrap_or` followed by a call to `default`
255
- --> $DIR/methods.rs:324 :5
263
+ --> $DIR/methods.rs:328 :5
256
264
|
257
265
LL | with_default_trait.unwrap_or(Default::default());
258
266
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`
259
267
260
268
error: use of `unwrap_or` followed by a call to `default`
261
- --> $DIR/methods.rs:327 :5
269
+ --> $DIR/methods.rs:331 :5
262
270
|
263
271
LL | with_default_type.unwrap_or(u64::default());
264
272
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
265
273
266
274
error: use of `unwrap_or` followed by a function call
267
- --> $DIR/methods.rs:330 :14
275
+ --> $DIR/methods.rs:334 :14
268
276
|
269
277
LL | with_vec.unwrap_or(vec![]);
270
278
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])`
271
279
272
280
error: use of `unwrap_or` followed by a function call
273
- --> $DIR/methods.rs:335 :21
281
+ --> $DIR/methods.rs:339 :21
274
282
|
275
283
LL | without_default.unwrap_or(Foo::new());
276
284
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
277
285
278
286
error: use of `or_insert` followed by a function call
279
- --> $DIR/methods.rs:338 :19
287
+ --> $DIR/methods.rs:342 :19
280
288
|
281
289
LL | map.entry(42).or_insert(String::new());
282
290
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
283
291
284
292
error: use of `or_insert` followed by a function call
285
- --> $DIR/methods.rs:341 :21
293
+ --> $DIR/methods.rs:345 :21
286
294
|
287
295
LL | btree.entry(42).or_insert(String::new());
288
296
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
289
297
290
298
error: use of `unwrap_or` followed by a function call
291
- --> $DIR/methods.rs:344 :21
299
+ --> $DIR/methods.rs:348 :21
292
300
|
293
301
LL | let _ = stringy.unwrap_or("".to_owned());
294
302
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
295
303
296
304
error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
297
- --> $DIR/methods.rs:355 :23
305
+ --> $DIR/methods.rs:359 :23
298
306
|
299
307
LL | let bad_vec = some_vec.iter().nth(3);
300
308
| ^^^^^^^^^^^^^^^^^^^^^^
301
309
|
302
310
= note: `-D clippy::iter-nth` implied by `-D warnings`
303
311
304
312
error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
305
- --> $DIR/methods.rs:356 :26
313
+ --> $DIR/methods.rs:360 :26
306
314
|
307
315
LL | let bad_slice = &some_vec[..].iter().nth(3);
308
316
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
309
317
310
318
error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
311
- --> $DIR/methods.rs:357 :31
319
+ --> $DIR/methods.rs:361 :31
312
320
|
313
321
LL | let bad_boxed_slice = boxed_slice.iter().nth(3);
314
322
| ^^^^^^^^^^^^^^^^^^^^^^^^^
315
323
316
324
error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
317
- --> $DIR/methods.rs:358 :29
325
+ --> $DIR/methods.rs:362 :29
318
326
|
319
327
LL | let bad_vec_deque = some_vec_deque.iter().nth(3);
320
328
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
321
329
322
330
error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
323
- --> $DIR/methods.rs:363 :23
331
+ --> $DIR/methods.rs:367 :23
324
332
|
325
333
LL | let bad_vec = some_vec.iter_mut().nth(3);
326
334
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
327
335
328
336
error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
329
- --> $DIR/methods.rs:366 :26
337
+ --> $DIR/methods.rs:370 :26
330
338
|
331
339
LL | let bad_slice = &some_vec[..].iter_mut().nth(3);
332
340
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
333
341
334
342
error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
335
- --> $DIR/methods.rs:369 :29
343
+ --> $DIR/methods.rs:373 :29
336
344
|
337
345
LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
338
346
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
339
347
340
348
error: used unwrap() on an Option value. If you don't want to handle the None case gracefully, consider using expect() to provide a better panic message
341
- --> $DIR/methods.rs:381 :13
349
+ --> $DIR/methods.rs:385 :13
342
350
|
343
351
LL | let _ = opt.unwrap();
344
352
| ^^^^^^^^^^^^
345
353
|
346
354
= note: `-D clippy::option-unwrap-used` implied by `-D warnings`
347
355
348
- error: aborting due to 43 previous errors
356
+ error: aborting due to 44 previous errors
349
357
0 commit comments