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:265:13
144 LL | let _ = v.iter().find(|&x| *x < 0).is_some();
145 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
147 = note: `-D clippy::search-is-some` implied by `-D warnings`
148 = note: replace `find(|&x| *x < 0).is_some()` with `any(|x| *x < 0)`
150 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
151 --> $DIR/methods.rs:268:13
153 LL | let _ = v.iter().find(|&x| {
158 | |______________________________^
160 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
161 --> $DIR/methods.rs:274:13
163 LL | let _ = v.iter().position(|&x| x < 0).is_some();
164 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
166 = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
168 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
169 --> $DIR/methods.rs:277:13
171 LL | let _ = v.iter().position(|&x| {
176 | |______________________________^
178 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
179 --> $DIR/methods.rs:283:13
181 LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
182 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
184 = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
186 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
187 --> $DIR/methods.rs:286:13
189 LL | let _ = v.iter().rposition(|&x| {
194 | |______________________________^
196 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
197 --> $DIR/methods.rs:301:13
199 LL | let _ = opt.unwrap();
202 = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
204 error: aborting due to 21 previous errors