1error: use Option::map_or instead of an if let/else 2 --> $DIR/option_if_let_else.rs:6:5 3 | 4LL | / if let Some(x) = string { 5LL | | (true, x) 6LL | | } else { 7LL | | (false, "hello") 8LL | | } 9 | |_____^ help: try: `string.map_or((false, "hello"), |x| (true, x))` 10 | 11 = note: `-D clippy::option-if-let-else` implied by `-D warnings` 12 13error: use Option::map_or instead of an if let/else 14 --> $DIR/option_if_let_else.rs:24:13 15 | 16LL | let _ = if let Some(s) = *string { s.len() } else { 0 }; 17 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())` 18 19error: use Option::map_or instead of an if let/else 20 --> $DIR/option_if_let_else.rs:25:13 21 | 22LL | let _ = if let Some(s) = &num { s } else { &0 }; 23 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` 24 25error: use Option::map_or instead of an if let/else 26 --> $DIR/option_if_let_else.rs:26:13 27 | 28LL | let _ = if let Some(s) = &mut num { 29 | _____________^ 30LL | | *s += 1; 31LL | | s 32LL | | } else { 33LL | | &mut 0 34LL | | }; 35 | |_____^ 36 | 37help: try 38 | 39LL ~ let _ = num.as_mut().map_or(&mut 0, |s| { 40LL + *s += 1; 41LL + s 42LL ~ }); 43 | 44 45error: use Option::map_or instead of an if let/else 46 --> $DIR/option_if_let_else.rs:32:13 47 | 48LL | let _ = if let Some(ref s) = num { s } else { &0 }; 49 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` 50 51error: use Option::map_or instead of an if let/else 52 --> $DIR/option_if_let_else.rs:33:13 53 | 54LL | let _ = if let Some(mut s) = num { 55 | _____________^ 56LL | | s += 1; 57LL | | s 58LL | | } else { 59LL | | 0 60LL | | }; 61 | |_____^ 62 | 63help: try 64 | 65LL ~ let _ = num.map_or(0, |mut s| { 66LL + s += 1; 67LL + s 68LL ~ }); 69 | 70 71error: use Option::map_or instead of an if let/else 72 --> $DIR/option_if_let_else.rs:39:13 73 | 74LL | let _ = if let Some(ref mut s) = num { 75 | _____________^ 76LL | | *s += 1; 77LL | | s 78LL | | } else { 79LL | | &mut 0 80LL | | }; 81 | |_____^ 82 | 83help: try 84 | 85LL ~ let _ = num.as_mut().map_or(&mut 0, |s| { 86LL + *s += 1; 87LL + s 88LL ~ }); 89 | 90 91error: use Option::map_or instead of an if let/else 92 --> $DIR/option_if_let_else.rs:48:5 93 | 94LL | / if let Some(x) = arg { 95LL | | let y = x * x; 96LL | | y * y 97LL | | } else { 98LL | | 13 99LL | | } 100 | |_____^ 101 | 102help: try 103 | 104LL ~ arg.map_or(13, |x| { 105LL + let y = x * x; 106LL + y * y 107LL + }) 108 | 109 110error: use Option::map_or_else instead of an if let/else 111 --> $DIR/option_if_let_else.rs:61:13 112 | 113LL | let _ = if let Some(x) = arg { 114 | _____________^ 115LL | | x 116LL | | } else { 117LL | | // map_or_else must be suggested 118LL | | side_effect() 119LL | | }; 120 | |_____^ help: try: `arg.map_or_else(|| side_effect(), |x| x)` 121 122error: use Option::map_or_else instead of an if let/else 123 --> $DIR/option_if_let_else.rs:70:13 124 | 125LL | let _ = if let Some(x) = arg { 126 | _____________^ 127LL | | x * x * x * x 128LL | | } else { 129LL | | let mut y = 1; 130... | 131LL | | y 132LL | | }; 133 | |_____^ 134 | 135help: try 136 | 137LL ~ let _ = arg.map_or_else(|| { 138LL + let mut y = 1; 139LL + y = (y + 2 / y) / 2; 140LL + y = (y + 2 / y) / 2; 141LL + y 142LL ~ }, |x| x * x * x * x); 143 | 144 145error: use Option::map_or instead of an if let/else 146 --> $DIR/option_if_let_else.rs:99:13 147 | 148LL | let _ = if let Some(x) = optional { x + 2 } else { 5 }; 149 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)` 150 151error: use Option::map_or instead of an if let/else 152 --> $DIR/option_if_let_else.rs:108:13 153 | 154LL | let _ = if let Some(x) = Some(0) { 155 | _____________^ 156LL | | loop { 157LL | | if x == 0 { 158LL | | break x; 159... | 160LL | | 0 161LL | | }; 162 | |_____^ 163 | 164help: try 165 | 166LL ~ let _ = Some(0).map_or(0, |x| loop { 167LL + if x == 0 { 168LL + break x; 169LL + } 170LL ~ }); 171 | 172 173error: use Option::map_or_else instead of an if let/else 174 --> $DIR/option_if_let_else.rs:136:13 175 | 176LL | 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)` 178 179error: use Option::map_or instead of an if let/else 180 --> $DIR/option_if_let_else.rs:140:13 181 | 182LL | let _ = if let Some(x) = Some(0) { 183 | _____________^ 184LL | | let s = s; 185LL | | s.len() + x 186LL | | } else { 187LL | | 1 188LL | | }; 189 | |_____^ 190 | 191help: try 192 | 193LL ~ let _ = Some(0).map_or(1, |x| { 194LL + let s = s; 195LL + s.len() + x 196LL ~ }); 197 | 198 199error: aborting due to 14 previous errors 200 201