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:37: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:153: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:175: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:179: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:183: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:188: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:190: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:194: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:205: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:209: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:213: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:217: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:247: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:250: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:267:13
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:268:13
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:269:13
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:272:13
164 LL | let _ = v.iter().find(|&x| {
169 | |______________________________^
171 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
172 --> $DIR/methods.rs:278:13
174 LL | let _ = v.iter().position(|&x| x < 0).is_some();
175 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|&x| x < 0)`
177 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
178 --> $DIR/methods.rs:281:13
180 LL | let _ = v.iter().position(|&x| {
185 | |______________________________^
187 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
188 --> $DIR/methods.rs:287:13
190 LL | let _ = v.iter().rposition(|&x| x < 0).is_some();
191 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|&x| x < 0)`
193 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
194 --> $DIR/methods.rs:290:13
196 LL | let _ = v.iter().rposition(|&x| {
201 | |______________________________^
203 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
204 --> $DIR/methods.rs:305:13
206 LL | let _ = opt.unwrap();
209 = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
211 error: aborting due to 23 previous errors