1 error: use Option::map_or instead of an if let/else
2 --> $DIR/option_if_let_else.rs:8: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:26: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:27: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:28: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:34: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:35: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:41: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:50: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:63: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:72: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 instead of an if let/else
146 --> $DIR/option_if_let_else.rs:101:13
148 LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
149 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
151 error: use Option::map_or instead of an if let/else
152 --> $DIR/option_if_let_else.rs:110:13
154 LL | let _ = if let Some(x) = Some(0) {
166 LL ~ let _ = Some(0).map_or(0, |x| loop {
173 error: use Option::map_or_else instead of an if let/else
174 --> $DIR/option_if_let_else.rs:138:13
176 LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() };
177 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or_else(|| s.len(), |x| s.len() + x)`
179 error: use Option::map_or instead of an if let/else
180 --> $DIR/option_if_let_else.rs:142:13
182 LL | let _ = if let Some(x) = Some(0) {
193 LL ~ let _ = Some(0).map_or(1, |x| {
199 error: aborting due to 14 previous errors