1 error: defining a method called `add` on this type; consider implementing the `std::ops::Add` trait or choosing a less ambiguous name
2 --> $DIR/methods.rs:35:5
4 LL | / pub fn add(self, other: T) -> T {
9 = note: `-D clippy::should-implement-trait` implied by `-D warnings`
11 error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name
12 --> $DIR/methods.rs:69:17
14 LL | fn into_u16(&self) -> u16 {
17 = note: `-D clippy::wrong-self-convention` implied by `-D warnings`
19 error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
20 --> $DIR/methods.rs:73:21
22 LL | fn to_something(self) -> u32 {
25 error: methods called `new` usually take no self; consider choosing a less ambiguous name
26 --> $DIR/methods.rs:77:12
28 LL | fn new(self) -> Self {
31 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
32 --> $DIR/methods.rs:157:13
34 LL | let _ = opt.map(|x| x + 1)
37 LL | | .unwrap_or(0); // should lint even though this call is on a separate line
38 | |____________________________^
40 = note: `-D clippy::option-map-unwrap-or` implied by `-D warnings`
41 = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)`
43 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
44 --> $DIR/methods.rs:161:13
46 LL | let _ = opt.map(|x| {
50 LL | | ).unwrap_or(0);
51 | |____________________________^
53 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
54 --> $DIR/methods.rs:165:13
56 LL | let _ = opt.map(|x| x + 1)
61 | |__________________^
63 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
64 --> $DIR/methods.rs:170:13
66 LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
67 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69 = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
71 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
72 --> $DIR/methods.rs:172:13
74 LL | let _ = opt.map(|x| {
78 LL | | ).unwrap_or(None);
79 | |_____________________^
81 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
82 --> $DIR/methods.rs:176:13
86 LL | | .map(|x| Some(x + 1))
87 LL | | .unwrap_or(None);
88 | |________________________^
90 = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
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
93 --> $DIR/methods.rs:187:13
95 LL | let _ = opt.map(|x| x + 1)
98 LL | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line
99 | |____________________________________^
101 = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings`
102 = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
104 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
107 LL | let _ = opt.map(|x| {
111 LL | | ).unwrap_or_else(|| 0);
112 | |____________________________________^
114 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
117 LL | let _ = opt.map(|x| x + 1)
119 LL | | .unwrap_or_else(||
122 | |_________________^
124 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
127 LL | let _ = opt.map_or(None, |x| Some(x + 1));
128 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))`
130 = note: `-D clippy::option-map-or-none` implied by `-D warnings`
132 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
135 LL | let _ = opt.map_or(None, |x| {
140 | |_________________^
141 help: try using and_then instead
143 LL | let _ = opt.and_then(|x| {
148 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
149 --> $DIR/methods.rs:232:13
151 LL | let _ = v.iter().filter(|&x| *x < 0).next();
152 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
154 = note: `-D clippy::filter-next` implied by `-D warnings`
155 = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
157 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
158 --> $DIR/methods.rs:235:13
160 LL | let _ = v.iter().filter(|&x| {
165 | |___________________________^
167 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
168 --> $DIR/methods.rs:251:13
170 LL | let _ = v.iter().find(|&x| *x < 0).is_some();
171 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
173 = note: `-D clippy::search-is-some` implied by `-D warnings`
174 = note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)`
176 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
177 --> $DIR/methods.rs:254:13
179 LL | let _ = v.iter().find(|&x| {
184 | |______________________________^
186 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
187 --> $DIR/methods.rs:260:13
189 LL | let _ = v.iter().position(|&x| x < 0).is_some();
190 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
192 = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
194 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
195 --> $DIR/methods.rs:263:13
197 LL | let _ = v.iter().position(|&x| {
202 | |______________________________^
204 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
205 --> $DIR/methods.rs:269:13
207 LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
208 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
210 = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
212 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
213 --> $DIR/methods.rs:272:13
215 LL | let _ = v.iter().rposition(|&x| {
220 | |______________________________^
222 error: use of `unwrap_or` followed by a function call
223 --> $DIR/methods.rs:309:22
225 LL | with_constructor.unwrap_or(make());
226 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
228 = note: `-D clippy::or-fun-call` implied by `-D warnings`
230 error: use of `unwrap_or` followed by a call to `new`
231 --> $DIR/methods.rs:312:5
233 LL | with_new.unwrap_or(Vec::new());
234 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()`
236 error: use of `unwrap_or` followed by a function call
237 --> $DIR/methods.rs:315:21
239 LL | with_const_args.unwrap_or(Vec::with_capacity(12));
240 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))`
242 error: use of `unwrap_or` followed by a function call
243 --> $DIR/methods.rs:318:14
245 LL | with_err.unwrap_or(make());
246 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())`
248 error: use of `unwrap_or` followed by a function call
249 --> $DIR/methods.rs:321:19
251 LL | with_err_args.unwrap_or(Vec::with_capacity(12));
252 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))`
254 error: use of `unwrap_or` followed by a call to `default`
255 --> $DIR/methods.rs:324:5
257 LL | with_default_trait.unwrap_or(Default::default());
258 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()`
260 error: use of `unwrap_or` followed by a call to `default`
261 --> $DIR/methods.rs:327:5
263 LL | with_default_type.unwrap_or(u64::default());
264 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()`
266 error: use of `unwrap_or` followed by a function call
267 --> $DIR/methods.rs:330:14
269 LL | with_vec.unwrap_or(vec![]);
270 | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])`
272 error: use of `unwrap_or` followed by a function call
273 --> $DIR/methods.rs:335:21
275 LL | without_default.unwrap_or(Foo::new());
276 | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)`
278 error: use of `or_insert` followed by a function call
279 --> $DIR/methods.rs:338:19
281 LL | map.entry(42).or_insert(String::new());
282 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
284 error: use of `or_insert` followed by a function call
285 --> $DIR/methods.rs:341:21
287 LL | btree.entry(42).or_insert(String::new());
288 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)`
290 error: use of `unwrap_or` followed by a function call
291 --> $DIR/methods.rs:344:21
293 LL | let _ = stringy.unwrap_or("".to_owned());
294 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
296 error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
297 --> $DIR/methods.rs:355:23
299 LL | let bad_vec = some_vec.iter().nth(3);
300 | ^^^^^^^^^^^^^^^^^^^^^^
302 = note: `-D clippy::iter-nth` implied by `-D warnings`
304 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
305 --> $DIR/methods.rs:356:26
307 LL | let bad_slice = &some_vec[..].iter().nth(3);
308 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
310 error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
311 --> $DIR/methods.rs:357:31
313 LL | let bad_boxed_slice = boxed_slice.iter().nth(3);
314 | ^^^^^^^^^^^^^^^^^^^^^^^^^
316 error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
317 --> $DIR/methods.rs:358:29
319 LL | let bad_vec_deque = some_vec_deque.iter().nth(3);
320 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
322 error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
323 --> $DIR/methods.rs:363:23
325 LL | let bad_vec = some_vec.iter_mut().nth(3);
326 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
328 error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
329 --> $DIR/methods.rs:366:26
331 LL | let bad_slice = &some_vec[..].iter_mut().nth(3);
332 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
334 error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
335 --> $DIR/methods.rs:369:29
337 LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
338 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
340 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
343 LL | let _ = opt.unwrap();
346 = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
348 error: aborting due to 43 previous errors