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:36: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 `new` usually return `Self`
12 --> $DIR/methods.rs:152:5
14 LL | / fn new() -> i32 {
19 = note: `-D clippy::new-ret-no-self` implied by `-D warnings`
21 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
22 --> $DIR/methods.rs:174:13
24 LL | let _ = opt.map(|x| x + 1)
26 LL | | // Should lint even though this call is on a separate line.
28 | |____________________________^
30 = note: `-D clippy::option-map-unwrap-or` implied by `-D warnings`
31 = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)`
33 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
34 --> $DIR/methods.rs:178:13
36 LL | let _ = opt.map(|x| {
40 LL | | ).unwrap_or(0);
41 | |____________________________^
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:182:13
46 LL | let _ = opt.map(|x| x + 1)
51 | |__________________^
53 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
54 --> $DIR/methods.rs:187:13
56 LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
57 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59 = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
61 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
62 --> $DIR/methods.rs:189:13
64 LL | let _ = opt.map(|x| {
68 LL | | ).unwrap_or(None);
69 | |_____________________^
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:193:13
76 LL | | .map(|x| Some(x + 1))
77 LL | | .unwrap_or(None);
78 | |________________________^
80 = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
82 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
83 --> $DIR/methods.rs:204:13
85 LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
86 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88 = note: replace `map(|p| format!("{}.", p)).unwrap_or(id)` with `map_or(id, |p| format!("{}.", p))`
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
91 --> $DIR/methods.rs:208:13
93 LL | let _ = opt.map(|x| x + 1)
95 LL | | // Should lint even though this call is on a separate line.
96 LL | | .unwrap_or_else(|| 0);
97 | |____________________________________^
99 = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings`
100 = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
102 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:212:13
105 LL | let _ = opt.map(|x| {
109 LL | | ).unwrap_or_else(|| 0);
110 | |____________________________________^
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
113 --> $DIR/methods.rs:216:13
115 LL | let _ = opt.map(|x| x + 1)
117 LL | | .unwrap_or_else(||
120 | |_________________^
122 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
123 --> $DIR/methods.rs:246:13
125 LL | let _ = v.iter().filter(|&x| *x < 0).next();
126 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
128 = note: `-D clippy::filter-next` implied by `-D warnings`
129 = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
131 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
132 --> $DIR/methods.rs:249:13
134 LL | let _ = v.iter().filter(|&x| {
139 | |___________________________^
141 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
142 --> $DIR/methods.rs:266:22
144 LL | let _ = v.iter().find(|&x| *x < 0).is_some();
145 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| *x < 0)`
147 = note: `-D clippy::search-is-some` implied by `-D warnings`
149 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
150 --> $DIR/methods.rs:267:20
152 LL | let _ = (0..1).find(|x| **y == *x).is_some(); // one dereference less
153 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| **y == x)`
155 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
156 --> $DIR/methods.rs:268:20
158 LL | let _ = (0..1).find(|x| *x == 0).is_some();
159 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| x == 0)`
161 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
162 --> $DIR/methods.rs:269:22
164 LL | let _ = v.iter().find(|x| **x == 0).is_some();
165 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| *x == 0)`
167 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
168 --> $DIR/methods.rs:272:13
170 LL | let _ = v.iter().find(|&x| {
175 | |______________________________^
177 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
178 --> $DIR/methods.rs:278:22
180 LL | let _ = v.iter().position(|&x| x < 0).is_some();
181 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|&x| x < 0)`
183 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
184 --> $DIR/methods.rs:281:13
186 LL | let _ = v.iter().position(|&x| {
191 | |______________________________^
193 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
194 --> $DIR/methods.rs:287:22
196 LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
197 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|&x| x < 0)`
199 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
200 --> $DIR/methods.rs:290:13
202 LL | let _ = v.iter().rposition(|&x| {
207 | |______________________________^
209 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
210 --> $DIR/methods.rs:305:13
212 LL | let _ = opt.unwrap();
215 = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
217 error: aborting due to 24 previous errors