1 error: use Option::map_or instead of an if let/else
2 --> $DIR/option_if_let_else.rs:7: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:17:12
16 LL | } else if let Some(x) = string {
18 LL | | Some((true, x))
20 LL | | Some((false, ""))
22 | |_____^ help: try: `{ string.map_or(Some((false, "")), |x| Some((true, x))) }`
24 error: use Option::map_or instead of an if let/else
25 --> $DIR/option_if_let_else.rs:25:13
27 LL | let _ = if let Some(s) = *string { s.len() } else { 0 };
28 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())`
30 error: use Option::map_or instead of an if let/else
31 --> $DIR/option_if_let_else.rs:26:13
33 LL | let _ = if let Some(s) = &num { s } else { &0 };
34 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
36 error: use Option::map_or instead of an if let/else
37 --> $DIR/option_if_let_else.rs:27:13
39 LL | let _ = if let Some(s) = &mut num {
50 LL | let _ = num.as_mut().map_or(&mut 0, |s| {
56 error: use Option::map_or instead of an if let/else
57 --> $DIR/option_if_let_else.rs:33:13
59 LL | let _ = if let Some(ref s) = num { s } else { &0 };
60 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
62 error: use Option::map_or instead of an if let/else
63 --> $DIR/option_if_let_else.rs:34:13
65 LL | let _ = if let Some(mut s) = num {
76 LL | let _ = num.map_or(0, |mut s| {
82 error: use Option::map_or instead of an if let/else
83 --> $DIR/option_if_let_else.rs:40:13
85 LL | let _ = if let Some(ref mut s) = num {
96 LL | let _ = num.as_mut().map_or(&mut 0, |s| {
102 error: use Option::map_or instead of an if let/else
103 --> $DIR/option_if_let_else.rs:49:5
105 LL | / if let Some(x) = arg {
106 LL | | let y = x * x;
115 LL | arg.map_or(13, |x| {
121 error: use Option::map_or_else instead of an if let/else
122 --> $DIR/option_if_let_else.rs:62:13
124 LL | let _ = if let Some(x) = arg {
128 LL | | // map_or_else must be suggested
131 | |_____^ help: try: `arg.map_or_else(|| side_effect(), |x| x)`
133 error: use Option::map_or_else instead of an if let/else
134 --> $DIR/option_if_let_else.rs:71:13
136 LL | let _ = if let Some(x) = arg {
140 LL | | let mut y = 1;
148 LL | let _ = arg.map_or_else(|| {
150 LL | y = (y + 2 / y) / 2;
151 LL | y = (y + 2 / y) / 2;
153 LL | }, |x| x * x * x * x);
156 error: use Option::map_or instead of an if let/else
157 --> $DIR/option_if_let_else.rs:100:13
159 LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
160 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
162 error: aborting due to 12 previous errors