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(&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(&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_else instead of an if let/else
156 --> $DIR/option_if_let_else.rs:120:5
158 LL | / if let Ok(binding) = variable {
159 LL | | println!("Ok {binding}");
161 LL | | println!("Err");
167 LL ~ variable.map_or_else(|_| {
168 LL + println!("Err");
170 LL + println!("Ok {binding}");
174 error: use Option::map_or instead of an if let/else
175 --> $DIR/option_if_let_else.rs:142:13
177 LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
178 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
180 error: use Option::map_or instead of an if let/else
181 --> $DIR/option_if_let_else.rs:152:13
183 LL | let _ = if let Some(x) = Some(0) {
195 LL ~ let _ = Some(0).map_or(0, |x| loop {
202 error: use Option::map_or instead of an if let/else
203 --> $DIR/option_if_let_else.rs:180:13
205 LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() };
206 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)`
208 error: use Option::map_or instead of an if let/else
209 --> $DIR/option_if_let_else.rs:184:13
211 LL | let _ = if let Some(x) = Some(0) {
222 LL ~ let _ = Some(0).map_or(1, |x| {
228 error: use Option::map_or instead of an if let/else
229 --> $DIR/option_if_let_else.rs:223:13
231 LL | let _ = match s {
233 LL | | Some(string) => string.len(),
236 | |_____^ help: try: `s.map_or(1, |string| string.len())`
238 error: use Option::map_or instead of an if let/else
239 --> $DIR/option_if_let_else.rs:227:13
241 LL | let _ = match Some(10) {
243 LL | | Some(a) => a + 1,
246 | |_____^ help: try: `Some(10).map_or(5, |a| a + 1)`
248 error: use Option::map_or instead of an if let/else
249 --> $DIR/option_if_let_else.rs:233:13
251 LL | let _ = match res {
253 LL | | Ok(a) => a + 1,
256 | |_____^ help: try: `res.map_or(1, |a| a + 1)`
258 error: use Option::map_or instead of an if let/else
259 --> $DIR/option_if_let_else.rs:237:13
261 LL | let _ = match res {
264 LL | | Ok(a) => a + 1,
266 | |_____^ help: try: `res.map_or(1, |a| a + 1)`
268 error: use Option::map_or instead of an if let/else
269 --> $DIR/option_if_let_else.rs:241:13
271 LL | let _ = if let Ok(a) = res { a + 1 } else { 5 };
272 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)`
274 error: use Option::map_or instead of an if let/else
275 --> $DIR/option_if_let_else.rs:258:9
277 LL | / match initial {
278 LL | | Some(value) => do_something(value),
281 | |_________^ help: try: `initial.as_ref().map_or({}, |value| do_something(value))`
283 error: use Option::map_or instead of an if let/else
284 --> $DIR/option_if_let_else.rs:265:9
286 LL | / match initial {
287 LL | | Some(value) => do_something2(value),
290 | |_________^ help: try: `initial.as_mut().map_or({}, |value| do_something2(value))`
292 error: aborting due to 23 previous errors