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