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:70: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:74: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:78: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:158:13
34 LL | let _ = opt.map(|x| x + 1)
36 LL | | // 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:162: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:166: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:171: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:173: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:177: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(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
93 --> $DIR/methods.rs:188:13
95 LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
96 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98 = note: replace `map(|p| format!("{}.", p)).unwrap_or(id)` with `map_or(id, |p| format!("{}.", p))`
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:192:13
103 LL | let _ = opt.map(|x| x + 1)
105 LL | | // Should lint even though this call is on a separate line.
106 LL | | .unwrap_or_else(|| 0);
107 | |____________________________________^
109 = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings`
110 = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
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:196:13
115 LL | let _ = opt.map(|x| {
119 LL | | ).unwrap_or_else(|| 0);
120 | |____________________________________^
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
123 --> $DIR/methods.rs:200:13
125 LL | let _ = opt.map(|x| x + 1)
127 LL | | .unwrap_or_else(||
130 | |_________________^
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:210:13
135 LL | let _ = opt.map_or(None, |x| Some(x + 1));
136 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))`
138 = note: `-D clippy::option-map-or-none` implied by `-D warnings`
140 error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead
141 --> $DIR/methods.rs:212:13
143 LL | let _ = opt.map_or(None, |x| {
148 | |_________________^
149 help: try using and_then instead
151 LL | let _ = opt.and_then(|x| {
156 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
157 --> $DIR/methods.rs:224:13
159 LL | let _ = v.iter().filter(|&x| *x < 0).next();
160 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
162 = note: `-D clippy::filter-next` implied by `-D warnings`
163 = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
165 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
166 --> $DIR/methods.rs:227:13
168 LL | let _ = v.iter().filter(|&x| {
173 | |___________________________^
175 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
176 --> $DIR/methods.rs:243:13
178 LL | let _ = v.iter().find(|&x| *x < 0).is_some();
179 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
181 = note: `-D clippy::search-is-some` implied by `-D warnings`
182 = note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)`
184 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
185 --> $DIR/methods.rs:246:13
187 LL | let _ = v.iter().find(|&x| {
192 | |______________________________^
194 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
195 --> $DIR/methods.rs:252:13
197 LL | let _ = v.iter().position(|&x| x < 0).is_some();
198 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
200 = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
202 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
203 --> $DIR/methods.rs:255:13
205 LL | let _ = v.iter().position(|&x| {
210 | |______________________________^
212 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
213 --> $DIR/methods.rs:261:13
215 LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
216 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
218 = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
220 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
221 --> $DIR/methods.rs:264:13
223 LL | let _ = v.iter().rposition(|&x| {
228 | |______________________________^
230 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
231 --> $DIR/methods.rs:279:13
233 LL | let _ = opt.unwrap();
236 = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
238 error: aborting due to 25 previous errors