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: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
12 --> $DIR/methods.rs:158:13
14 LL | let _ = opt.map(|x| x + 1)
16 LL | | // Should lint even though this call is on a separate line.
18 | |____________________________^
20 = note: `-D clippy::option-map-unwrap-or` implied by `-D warnings`
21 = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)`
23 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
24 --> $DIR/methods.rs:162:13
26 LL | let _ = opt.map(|x| {
30 LL | | ).unwrap_or(0);
31 | |____________________________^
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:166:13
36 LL | let _ = opt.map(|x| x + 1)
41 | |__________________^
43 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
44 --> $DIR/methods.rs:171:13
46 LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
47 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
49 = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
51 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
52 --> $DIR/methods.rs:173:13
54 LL | let _ = opt.map(|x| {
58 LL | | ).unwrap_or(None);
59 | |_____________________^
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:177:13
66 LL | | .map(|x| Some(x + 1))
67 LL | | .unwrap_or(None);
68 | |________________________^
70 = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
72 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
73 --> $DIR/methods.rs:188:13
75 LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
76 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
78 = note: replace `map(|p| format!("{}.", p)).unwrap_or(id)` with `map_or(id, |p| format!("{}.", p))`
80 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
81 --> $DIR/methods.rs:192:13
83 LL | let _ = opt.map(|x| x + 1)
85 LL | | // Should lint even though this call is on a separate line.
86 LL | | .unwrap_or_else(|| 0);
87 | |____________________________________^
89 = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings`
90 = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| 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:196:13
95 LL | let _ = opt.map(|x| {
99 LL | | ).unwrap_or_else(|| 0);
100 | |____________________________________^
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:200:13
105 LL | let _ = opt.map(|x| x + 1)
107 LL | | .unwrap_or_else(||
110 | |_________________^
112 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
113 --> $DIR/methods.rs:230:13
115 LL | let _ = v.iter().filter(|&x| *x < 0).next();
116 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
118 = note: `-D clippy::filter-next` implied by `-D warnings`
119 = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
121 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
122 --> $DIR/methods.rs:233:13
124 LL | let _ = v.iter().filter(|&x| {
129 | |___________________________^
131 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
132 --> $DIR/methods.rs:249:13
134 LL | let _ = v.iter().find(|&x| *x < 0).is_some();
135 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
137 = note: `-D clippy::search-is-some` implied by `-D warnings`
138 = note: replace `find(|&x| *x < 0).is_some()` with `any(|x| *x < 0)`
140 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
141 --> $DIR/methods.rs:252:13
143 LL | let _ = v.iter().find(|&x| {
148 | |______________________________^
150 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
151 --> $DIR/methods.rs:258:13
153 LL | let _ = v.iter().position(|&x| x < 0).is_some();
154 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156 = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
158 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
159 --> $DIR/methods.rs:261:13
161 LL | let _ = v.iter().position(|&x| {
166 | |______________________________^
168 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
169 --> $DIR/methods.rs:267:13
171 LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
172 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
174 = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
176 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
177 --> $DIR/methods.rs:270:13
179 LL | let _ = v.iter().rposition(|&x| {
184 | |______________________________^
186 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
187 --> $DIR/methods.rs:285:13
189 LL | let _ = opt.unwrap();
192 = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
194 error: aborting due to 20 previous errors