11error: use Option::map_or instead of an if let/else
2- --> $DIR/option_if_let_else.rs:12 :5
2+ --> $DIR/option_if_let_else.rs:11 :5
33 |
44LL | / if let Some(x) = string {
55LL | | (true, x)
@@ -12,19 +12,19 @@ LL | | }
1212 = help: to override `-D warnings` add `#[allow(clippy::option_if_let_else)]`
1313
1414error: use Option::map_or instead of an if let/else
15- --> $DIR/option_if_let_else.rs:30 :13
15+ --> $DIR/option_if_let_else.rs:29 :13
1616 |
1717LL | let _ = if let Some(s) = *string { s.len() } else { 0 };
1818 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())`
1919
2020error: use Option::map_or instead of an if let/else
21- --> $DIR/option_if_let_else.rs:31 :13
21+ --> $DIR/option_if_let_else.rs:30 :13
2222 |
2323LL | let _ = if let Some(s) = &num { s } else { &0 };
2424 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
2525
2626error: use Option::map_or instead of an if let/else
27- --> $DIR/option_if_let_else.rs:32 :13
27+ --> $DIR/option_if_let_else.rs:31 :13
2828 |
2929LL | let _ = if let Some(s) = &mut num {
3030 | _____________^
@@ -44,13 +44,13 @@ LL ~ });
4444 |
4545
4646error: use Option::map_or instead of an if let/else
47- --> $DIR/option_if_let_else.rs:38 :13
47+ --> $DIR/option_if_let_else.rs:37 :13
4848 |
4949LL | let _ = if let Some(ref s) = num { s } else { &0 };
5050 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
5151
5252error: use Option::map_or instead of an if let/else
53- --> $DIR/option_if_let_else.rs:39 :13
53+ --> $DIR/option_if_let_else.rs:38 :13
5454 |
5555LL | let _ = if let Some(mut s) = num {
5656 | _____________^
@@ -70,7 +70,7 @@ LL ~ });
7070 |
7171
7272error: use Option::map_or instead of an if let/else
73- --> $DIR/option_if_let_else.rs:45 :13
73+ --> $DIR/option_if_let_else.rs:44 :13
7474 |
7575LL | let _ = if let Some(ref mut s) = num {
7676 | _____________^
@@ -90,7 +90,7 @@ LL ~ });
9090 |
9191
9292error: use Option::map_or instead of an if let/else
93- --> $DIR/option_if_let_else.rs:54 :5
93+ --> $DIR/option_if_let_else.rs:53 :5
9494 |
9595LL | / if let Some(x) = arg {
9696LL | | let y = x * x;
@@ -109,7 +109,7 @@ LL + })
109109 |
110110
111111error: use Option::map_or_else instead of an if let/else
112- --> $DIR/option_if_let_else.rs:67 :13
112+ --> $DIR/option_if_let_else.rs:66 :13
113113 |
114114LL | let _ = if let Some(x) = arg {
115115 | _____________^
@@ -118,10 +118,10 @@ LL | | } else {
118118LL | | // map_or_else must be suggested
119119LL | | side_effect()
120120LL | | };
121- | |_____^ help: try: `arg.map_or_else(|| side_effect() , |x| x)`
121+ | |_____^ help: try: `arg.map_or_else(side_effect, |x| x)`
122122
123123error: use Option::map_or_else instead of an if let/else
124- --> $DIR/option_if_let_else.rs:76 :13
124+ --> $DIR/option_if_let_else.rs:75 :13
125125 |
126126LL | let _ = if let Some(x) = arg {
127127 | _____________^
@@ -144,7 +144,7 @@ LL ~ }, |x| x * x * x * x);
144144 |
145145
146146error: use Option::map_or_else instead of an if let/else
147- --> $DIR/option_if_let_else.rs:109 :13
147+ --> $DIR/option_if_let_else.rs:108 :13
148148 |
149149LL | / if let Some(idx) = s.find('.') {
150150LL | | vec![s[..idx].to_string(), s[idx..].to_string()]
@@ -154,7 +154,7 @@ LL | | }
154154 | |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])`
155155
156156error: use Option::map_or_else instead of an if let/else
157- --> $DIR/option_if_let_else.rs:120 :5
157+ --> $DIR/option_if_let_else.rs:119 :5
158158 |
159159LL | / if let Ok(binding) = variable {
160160LL | | println!("Ok {binding}");
@@ -173,13 +173,13 @@ LL + })
173173 |
174174
175175error: use Option::map_or instead of an if let/else
176- --> $DIR/option_if_let_else.rs:142 :13
176+ --> $DIR/option_if_let_else.rs:141 :13
177177 |
178178LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
179179 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
180180
181181error: use Option::map_or instead of an if let/else
182- --> $DIR/option_if_let_else.rs:152 :13
182+ --> $DIR/option_if_let_else.rs:151 :13
183183 |
184184LL | let _ = if let Some(x) = Some(0) {
185185 | _____________^
@@ -201,13 +201,13 @@ LL ~ });
201201 |
202202
203203error: use Option::map_or instead of an if let/else
204- --> $DIR/option_if_let_else.rs:180 :13
204+ --> $DIR/option_if_let_else.rs:179 :13
205205 |
206206LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() };
207207 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)`
208208
209209error: use Option::map_or instead of an if let/else
210- --> $DIR/option_if_let_else.rs:184 :13
210+ --> $DIR/option_if_let_else.rs:183 :13
211211 |
212212LL | let _ = if let Some(x) = Some(0) {
213213 | _____________^
@@ -227,7 +227,7 @@ LL ~ });
227227 |
228228
229229error: use Option::map_or instead of an if let/else
230- --> $DIR/option_if_let_else.rs:223 :13
230+ --> $DIR/option_if_let_else.rs:222 :13
231231 |
232232LL | let _ = match s {
233233 | _____________^
@@ -237,7 +237,7 @@ LL | | };
237237 | |_____^ help: try: `s.map_or(1, |string| string.len())`
238238
239239error: use Option::map_or instead of an if let/else
240- --> $DIR/option_if_let_else.rs:227 :13
240+ --> $DIR/option_if_let_else.rs:226 :13
241241 |
242242LL | let _ = match Some(10) {
243243 | _____________^
@@ -247,7 +247,7 @@ LL | | };
247247 | |_____^ help: try: `Some(10).map_or(5, |a| a + 1)`
248248
249249error: use Option::map_or instead of an if let/else
250- --> $DIR/option_if_let_else.rs:233 :13
250+ --> $DIR/option_if_let_else.rs:232 :13
251251 |
252252LL | let _ = match res {
253253 | _____________^
@@ -257,7 +257,7 @@ LL | | };
257257 | |_____^ help: try: `res.map_or(1, |a| a + 1)`
258258
259259error: use Option::map_or instead of an if let/else
260- --> $DIR/option_if_let_else.rs:237 :13
260+ --> $DIR/option_if_let_else.rs:236 :13
261261 |
262262LL | let _ = match res {
263263 | _____________^
@@ -267,13 +267,13 @@ LL | | };
267267 | |_____^ help: try: `res.map_or(1, |a| a + 1)`
268268
269269error: use Option::map_or instead of an if let/else
270- --> $DIR/option_if_let_else.rs:241 :13
270+ --> $DIR/option_if_let_else.rs:240 :13
271271 |
272272LL | let _ = if let Ok(a) = res { a + 1 } else { 5 };
273273 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)`
274274
275275error: use Option::map_or instead of an if let/else
276- --> $DIR/option_if_let_else.rs:258 :9
276+ --> $DIR/option_if_let_else.rs:257 :9
277277 |
278278LL | / match initial {
279279LL | | Some(value) => do_something(value),
@@ -282,13 +282,30 @@ LL | | }
282282 | |_________^ help: try: `initial.as_ref().map_or({}, |value| do_something(value))`
283283
284284error: use Option::map_or instead of an if let/else
285- --> $DIR/option_if_let_else.rs:265 :9
285+ --> $DIR/option_if_let_else.rs:264 :9
286286 |
287287LL | / match initial {
288288LL | | Some(value) => do_something2(value),
289289LL | | None => {},
290290LL | | }
291291 | |_________^ help: try: `initial.as_mut().map_or({}, |value| do_something2(value))`
292292
293- error: aborting due to 23 previous errors
293+ error: use Option::map_or_else instead of an if let/else
294+ --> $DIR/option_if_let_else.rs:283:24
295+ |
296+ LL | let mut _hashmap = if let Some(hm) = &opt {
297+ | ________________________^
298+ LL | | hm.clone()
299+ LL | | } else {
300+ LL | | HashMap::new()
301+ LL | | };
302+ | |_____^ help: try: `opt.as_ref().map_or_else(HashMap::new, |hm| hm.clone())`
303+
304+ error: use Option::map_or_else instead of an if let/else
305+ --> $DIR/option_if_let_else.rs:289:19
306+ |
307+ LL | let mut _hm = if let Some(hm) = &opt { hm.clone() } else { new_map!() };
308+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.as_ref().map_or_else(|| new_map!(), |hm| hm.clone())`
309+
310+ error: aborting due to 25 previous errors
294311
0 commit comments