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)
@@ -11,19 +11,19 @@ LL | | }
1111 = note: `-D clippy::option-if-let-else` implied by `-D warnings`
1212
1313error: use Option::map_or instead of an if let/else
14- --> $DIR/option_if_let_else.rs:30 :13
14+ --> $DIR/option_if_let_else.rs:29 :13
1515 |
1616LL | let _ = if let Some(s) = *string { s.len() } else { 0 };
1717 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())`
1818
1919error: use Option::map_or instead of an if let/else
20- --> $DIR/option_if_let_else.rs:31 :13
20+ --> $DIR/option_if_let_else.rs:30 :13
2121 |
2222LL | let _ = if let Some(s) = &num { s } else { &0 };
2323 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
2424
2525error: use Option::map_or instead of an if let/else
26- --> $DIR/option_if_let_else.rs:32 :13
26+ --> $DIR/option_if_let_else.rs:31 :13
2727 |
2828LL | let _ = if let Some(s) = &mut num {
2929 | _____________^
@@ -43,13 +43,13 @@ LL ~ });
4343 |
4444
4545error: use Option::map_or instead of an if let/else
46- --> $DIR/option_if_let_else.rs:38 :13
46+ --> $DIR/option_if_let_else.rs:37 :13
4747 |
4848LL | let _ = if let Some(ref s) = num { s } else { &0 };
4949 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
5050
5151error: use Option::map_or instead of an if let/else
52- --> $DIR/option_if_let_else.rs:39 :13
52+ --> $DIR/option_if_let_else.rs:38 :13
5353 |
5454LL | let _ = if let Some(mut s) = num {
5555 | _____________^
@@ -69,7 +69,7 @@ LL ~ });
6969 |
7070
7171error: use Option::map_or instead of an if let/else
72- --> $DIR/option_if_let_else.rs:45 :13
72+ --> $DIR/option_if_let_else.rs:44 :13
7373 |
7474LL | let _ = if let Some(ref mut s) = num {
7575 | _____________^
@@ -89,7 +89,7 @@ LL ~ });
8989 |
9090
9191error: use Option::map_or instead of an if let/else
92- --> $DIR/option_if_let_else.rs:54 :5
92+ --> $DIR/option_if_let_else.rs:53 :5
9393 |
9494LL | / if let Some(x) = arg {
9595LL | | let y = x * x;
@@ -108,7 +108,7 @@ LL + })
108108 |
109109
110110error: use Option::map_or_else instead of an if let/else
111- --> $DIR/option_if_let_else.rs:67 :13
111+ --> $DIR/option_if_let_else.rs:66 :13
112112 |
113113LL | let _ = if let Some(x) = arg {
114114 | _____________^
@@ -117,10 +117,10 @@ LL | | } else {
117117LL | | // map_or_else must be suggested
118118LL | | side_effect()
119119LL | | };
120- | |_____^ help: try: `arg.map_or_else(|| side_effect() , |x| x)`
120+ | |_____^ help: try: `arg.map_or_else(side_effect, |x| x)`
121121
122122error: use Option::map_or_else instead of an if let/else
123- --> $DIR/option_if_let_else.rs:76 :13
123+ --> $DIR/option_if_let_else.rs:75 :13
124124 |
125125LL | let _ = if let Some(x) = arg {
126126 | _____________^
@@ -143,7 +143,7 @@ LL ~ }, |x| x * x * x * x);
143143 |
144144
145145error: use Option::map_or_else instead of an if let/else
146- --> $DIR/option_if_let_else.rs:109 :13
146+ --> $DIR/option_if_let_else.rs:108 :13
147147 |
148148LL | / if let Some(idx) = s.find('.') {
149149LL | | vec![s[..idx].to_string(), s[idx..].to_string()]
@@ -153,7 +153,7 @@ LL | | }
153153 | |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])`
154154
155155error: use Option::map_or_else instead of an if let/else
156- --> $DIR/option_if_let_else.rs:120 :5
156+ --> $DIR/option_if_let_else.rs:119 :5
157157 |
158158LL | / if let Ok(binding) = variable {
159159LL | | println!("Ok {binding}");
@@ -172,13 +172,13 @@ LL + })
172172 |
173173
174174error: use Option::map_or instead of an if let/else
175- --> $DIR/option_if_let_else.rs:142 :13
175+ --> $DIR/option_if_let_else.rs:141 :13
176176 |
177177LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
178178 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
179179
180180error: use Option::map_or instead of an if let/else
181- --> $DIR/option_if_let_else.rs:152 :13
181+ --> $DIR/option_if_let_else.rs:151 :13
182182 |
183183LL | let _ = if let Some(x) = Some(0) {
184184 | _____________^
@@ -200,13 +200,13 @@ LL ~ });
200200 |
201201
202202error: use Option::map_or instead of an if let/else
203- --> $DIR/option_if_let_else.rs:180 :13
203+ --> $DIR/option_if_let_else.rs:179 :13
204204 |
205205LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() };
206206 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)`
207207
208208error: use Option::map_or instead of an if let/else
209- --> $DIR/option_if_let_else.rs:184 :13
209+ --> $DIR/option_if_let_else.rs:183 :13
210210 |
211211LL | let _ = if let Some(x) = Some(0) {
212212 | _____________^
@@ -226,7 +226,7 @@ LL ~ });
226226 |
227227
228228error: use Option::map_or instead of an if let/else
229- --> $DIR/option_if_let_else.rs:223 :13
229+ --> $DIR/option_if_let_else.rs:222 :13
230230 |
231231LL | let _ = match s {
232232 | _____________^
@@ -236,7 +236,7 @@ LL | | };
236236 | |_____^ help: try: `s.map_or(1, |string| string.len())`
237237
238238error: use Option::map_or instead of an if let/else
239- --> $DIR/option_if_let_else.rs:227 :13
239+ --> $DIR/option_if_let_else.rs:226 :13
240240 |
241241LL | let _ = match Some(10) {
242242 | _____________^
@@ -246,7 +246,7 @@ LL | | };
246246 | |_____^ help: try: `Some(10).map_or(5, |a| a + 1)`
247247
248248error: use Option::map_or instead of an if let/else
249- --> $DIR/option_if_let_else.rs:233 :13
249+ --> $DIR/option_if_let_else.rs:232 :13
250250 |
251251LL | let _ = match res {
252252 | _____________^
@@ -256,7 +256,7 @@ LL | | };
256256 | |_____^ help: try: `res.map_or(1, |a| a + 1)`
257257
258258error: use Option::map_or instead of an if let/else
259- --> $DIR/option_if_let_else.rs:237 :13
259+ --> $DIR/option_if_let_else.rs:236 :13
260260 |
261261LL | let _ = match res {
262262 | _____________^
@@ -266,13 +266,13 @@ LL | | };
266266 | |_____^ help: try: `res.map_or(1, |a| a + 1)`
267267
268268error: use Option::map_or instead of an if let/else
269- --> $DIR/option_if_let_else.rs:241 :13
269+ --> $DIR/option_if_let_else.rs:240 :13
270270 |
271271LL | let _ = if let Ok(a) = res { a + 1 } else { 5 };
272272 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)`
273273
274274error: use Option::map_or instead of an if let/else
275- --> $DIR/option_if_let_else.rs:258 :9
275+ --> $DIR/option_if_let_else.rs:257 :9
276276 |
277277LL | / match initial {
278278LL | | Some(value) => do_something(value),
@@ -281,13 +281,30 @@ LL | | }
281281 | |_________^ help: try: `initial.as_ref().map_or({}, |value| do_something(value))`
282282
283283error: use Option::map_or instead of an if let/else
284- --> $DIR/option_if_let_else.rs:265 :9
284+ --> $DIR/option_if_let_else.rs:264 :9
285285 |
286286LL | / match initial {
287287LL | | Some(value) => do_something2(value),
288288LL | | None => {},
289289LL | | }
290290 | |_________^ help: try: `initial.as_mut().map_or({}, |value| do_something2(value))`
291291
292- error: aborting due to 23 previous errors
292+ error: use Option::map_or_else instead of an if let/else
293+ --> $DIR/option_if_let_else.rs:283:24
294+ |
295+ LL | let mut _hashmap = if let Some(hm) = &opt {
296+ | ________________________^
297+ LL | | hm.clone()
298+ LL | | } else {
299+ LL | | HashMap::new()
300+ LL | | };
301+ | |_____^ help: try: `opt.as_ref().map_or_else(HashMap::new, |hm| hm.clone())`
302+
303+ error: use Option::map_or_else instead of an if let/else
304+ --> $DIR/option_if_let_else.rs:289:19
305+ |
306+ LL | let mut _hm = if let Some(hm) = &opt { hm.clone() } else { new_map!() };
307+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.as_ref().map_or_else(|| new_map!(), |hm| hm.clone())`
308+
309+ error: aborting due to 25 previous errors
293310
0 commit comments