1 error: use Option::map_or instead of an if let/else
2 --> $DIR/option_if_let_else.rs:12:5
4 LL | / if let Some(x) = string {
7 LL | | (false, "hello")
9 | |_____^ help: try: `string.map_or((false, "hello"), |x| (true, x))`
11 = note: `-D clippy::option-if-let-else` implied by `-D warnings`
13 error: use Option::map_or instead of an if let/else
14 --> $DIR/option_if_let_else.rs:30:13
16 LL | let _ = if let Some(s) = *string { s.len() } else { 0 };
17 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())`
19 error: use Option::map_or instead of an if let/else
20 --> $DIR/option_if_let_else.rs:31:13
22 LL | let _ = if let Some(s) = &num { s } else { &0 };
23 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
25 error: use Option::map_or instead of an if let/else
26 --> $DIR/option_if_let_else.rs:32:13
28 LL | let _ = if let Some(s) = &mut num {
39 LL ~ let _ = num.as_mut().map_or(&mut 0, |s| {
45 error: use Option::map_or instead of an if let/else
46 --> $DIR/option_if_let_else.rs:38:13
48 LL | let _ = if let Some(ref s) = num { s } else { &0 };
49 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
51 error: use Option::map_or instead of an if let/else
52 --> $DIR/option_if_let_else.rs:39:13
54 LL | let _ = if let Some(mut s) = num {
65 LL ~ let _ = num.map_or(0, |mut s| {
71 error: use Option::map_or instead of an if let/else
72 --> $DIR/option_if_let_else.rs:45:13
74 LL | let _ = if let Some(ref mut s) = num {
85 LL ~ let _ = num.as_mut().map_or(&mut 0, |s| {
91 error: use Option::map_or instead of an if let/else
92 --> $DIR/option_if_let_else.rs:54:5
94 LL | / if let Some(x) = arg {
104 LL ~ arg.map_or(13, |x| {
110 error: use Option::map_or_else instead of an if let/else
111 --> $DIR/option_if_let_else.rs:67:13
113 LL | let _ = if let Some(x) = arg {
117 LL | | // map_or_else must be suggested
120 | |_____^ help: try: `arg.map_or_else(|| side_effect(), |x| x)`
122 error: use Option::map_or_else instead of an if let/else
123 --> $DIR/option_if_let_else.rs:76:13
125 LL | let _ = if let Some(x) = arg {
129 LL | | let mut y = 1;
137 LL ~ let _ = arg.map_or_else(|| {
139 LL + y = (y + 2 / y) / 2;
140 LL + y = (y + 2 / y) / 2;
142 LL ~ }, |x| x * x * x * x);
145 error: use Option::map_or_else instead of an if let/else
146 --> $DIR/option_if_let_else.rs:109:13
148 LL | / if let Some(idx) = s.find('.') {
149 LL | | vec![s[..idx].to_string(), s[idx..].to_string()]
151 LL | | vec![s.to_string()]
153 | |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])`
155 error: use Option::map_or instead of an if let/else
156 --> $DIR/option_if_let_else.rs:133:13
158 LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
159 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
161 error: use Option::map_or instead of an if let/else
162 --> $DIR/option_if_let_else.rs:142:13
164 LL | let _ = if let Some(x) = Some(0) {
176 LL ~ let _ = Some(0).map_or(0, |x| loop {
183 error: use Option::map_or instead of an if let/else
184 --> $DIR/option_if_let_else.rs:170:13
186 LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() };
187 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)`
189 error: use Option::map_or instead of an if let/else
190 --> $DIR/option_if_let_else.rs:174:13
192 LL | let _ = if let Some(x) = Some(0) {
203 LL ~ let _ = Some(0).map_or(1, |x| {
209 error: use Option::map_or instead of an if let/else
210 --> $DIR/option_if_let_else.rs:213:13
212 LL | let _ = match s {
214 LL | | Some(string) => string.len(),
217 | |_____^ help: try: `s.map_or(1, |string| string.len())`
219 error: use Option::map_or instead of an if let/else
220 --> $DIR/option_if_let_else.rs:217:13
222 LL | let _ = match Some(10) {
224 LL | | Some(a) => a + 1,
227 | |_____^ help: try: `Some(10).map_or(5, |a| a + 1)`
229 error: use Option::map_or instead of an if let/else
230 --> $DIR/option_if_let_else.rs:223:13
232 LL | let _ = match res {
234 LL | | Ok(a) => a + 1,
237 | |_____^ help: try: `res.map_or(1, |a| a + 1)`
239 error: use Option::map_or instead of an if let/else
240 --> $DIR/option_if_let_else.rs:227:13
242 LL | let _ = match res {
245 LL | | Ok(a) => a + 1,
247 | |_____^ help: try: `res.map_or(1, |a| a + 1)`
249 error: use Option::map_or instead of an if let/else
250 --> $DIR/option_if_let_else.rs:231:13
252 LL | let _ = if let Ok(a) = res { a + 1 } else { 5 };
253 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)`
255 error: aborting due to 20 previous errors