2020-07-14 12:59:59 +00:00
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:11:5
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
LL | / if let Some(x) = string {
|
|
|
|
LL | | (true, x)
|
|
|
|
LL | | } else {
|
|
|
|
LL | | (false, "hello")
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: try: `string.map_or((false, "hello"), |x| (true, x))`
|
|
|
|
|
|
|
|
|
= note: `-D clippy::option-if-let-else` implied by `-D warnings`
|
2023-08-01 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::option_if_let_else)]`
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:29:13
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(s) = *string { s.len() } else { 0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())`
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:30:13
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(s) = &num { s } else { &0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:31:13
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(s) = &mut num {
|
|
|
|
| _____________^
|
|
|
|
LL | | *s += 1;
|
|
|
|
LL | | s
|
|
|
|
LL | | } else {
|
2022-11-24 19:09:27 +00:00
|
|
|
LL | | &0
|
2020-07-14 12:59:59 +00:00
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2022-11-24 19:09:27 +00:00
|
|
|
LL ~ let _ = num.as_mut().map_or(&0, |s| {
|
2021-08-11 14:21:33 +00:00
|
|
|
LL + *s += 1;
|
|
|
|
LL + s
|
|
|
|
LL ~ });
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:37:13
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(ref s) = num { s } else { &0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:38:13
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(mut s) = num {
|
|
|
|
| _____________^
|
|
|
|
LL | | s += 1;
|
|
|
|
LL | | s
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 0
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~ let _ = num.map_or(0, |mut s| {
|
|
|
|
LL + s += 1;
|
|
|
|
LL + s
|
|
|
|
LL ~ });
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:44:13
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(ref mut s) = num {
|
|
|
|
| _____________^
|
|
|
|
LL | | *s += 1;
|
|
|
|
LL | | s
|
|
|
|
LL | | } else {
|
2022-11-24 19:09:27 +00:00
|
|
|
LL | | &0
|
2020-07-14 12:59:59 +00:00
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2022-11-24 19:09:27 +00:00
|
|
|
LL ~ let _ = num.as_mut().map_or(&0, |s| {
|
2021-08-11 14:21:33 +00:00
|
|
|
LL + *s += 1;
|
|
|
|
LL + s
|
|
|
|
LL ~ });
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:53:5
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
LL | / if let Some(x) = arg {
|
|
|
|
LL | | let y = x * x;
|
|
|
|
LL | | y * y
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 13
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~ arg.map_or(13, |x| {
|
|
|
|
LL + let y = x * x;
|
|
|
|
LL + y * y
|
|
|
|
LL + })
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: use Option::map_or_else instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:66:13
|
2020-09-24 12:49:22 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(x) = arg {
|
|
|
|
| _____________^
|
|
|
|
LL | | x
|
|
|
|
LL | | } else {
|
|
|
|
LL | | // map_or_else must be suggested
|
|
|
|
LL | | side_effect()
|
|
|
|
LL | | };
|
2023-09-04 08:15:45 +00:00
|
|
|
| |_____^ help: try: `arg.map_or_else(side_effect, |x| x)`
|
2020-09-24 12:49:22 +00:00
|
|
|
|
|
|
|
error: use Option::map_or_else instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:75:13
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(x) = arg {
|
|
|
|
| _____________^
|
|
|
|
LL | | x * x * x * x
|
|
|
|
LL | | } else {
|
|
|
|
LL | | let mut y = 1;
|
|
|
|
... |
|
|
|
|
LL | | y
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~ let _ = arg.map_or_else(|| {
|
|
|
|
LL + let mut y = 1;
|
|
|
|
LL + y = (y + 2 / y) / 2;
|
|
|
|
LL + y = (y + 2 / y) / 2;
|
|
|
|
LL + y
|
|
|
|
LL ~ }, |x| x * x * x * x);
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
|
2021-12-06 11:33:31 +00:00
|
|
|
error: use Option::map_or_else instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:108:13
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
LL | / if let Some(idx) = s.find('.') {
|
|
|
|
LL | | vec![s[..idx].to_string(), s[idx..].to_string()]
|
|
|
|
LL | | } else {
|
|
|
|
LL | | vec![s.to_string()]
|
|
|
|
LL | | }
|
|
|
|
| |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])`
|
|
|
|
|
2023-05-20 13:39:26 +00:00
|
|
|
error: use Option::map_or_else instead of an if let/else
|
2023-09-04 08:15:45 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:119:5
|
2023-05-20 13:39:26 +00:00
|
|
|
|
|
|
|
|
LL | / if let Ok(binding) = variable {
|
|
|
|
LL | | println!("Ok {binding}");
|
2023-11-29 18:22:28 +00:00
|
|
|
LL | | true
|
2023-05-20 13:39:26 +00:00
|
|
|
LL | | } else {
|
|
|
|
LL | | println!("Err");
|
2023-11-29 18:22:28 +00:00
|
|
|
LL | | false
|
2023-05-20 13:39:26 +00:00
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
|
|
|
LL ~ variable.map_or_else(|_| {
|
|
|
|
LL + println!("Err");
|
2023-11-29 18:22:28 +00:00
|
|
|
LL + false
|
2023-05-20 13:39:26 +00:00
|
|
|
LL + }, |binding| {
|
|
|
|
LL + println!("Ok {binding}");
|
2023-11-29 18:22:28 +00:00
|
|
|
LL + true
|
2023-05-20 13:39:26 +00:00
|
|
|
LL + })
|
|
|
|
|
|
|
|
|
|
2020-07-14 12:59:59 +00:00
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:143:13
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
|
|
|
|
|
2021-09-08 14:31:47 +00:00
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:153:13
|
2021-09-08 14:31:47 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(x) = Some(0) {
|
|
|
|
| _____________^
|
|
|
|
LL | | loop {
|
|
|
|
LL | | if x == 0 {
|
|
|
|
LL | | break x;
|
|
|
|
... |
|
|
|
|
LL | | 0
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
|
|
|
LL ~ let _ = Some(0).map_or(0, |x| loop {
|
|
|
|
LL + if x == 0 {
|
|
|
|
LL + break x;
|
|
|
|
LL + }
|
|
|
|
LL ~ });
|
|
|
|
|
|
|
|
|
|
2021-12-06 11:33:31 +00:00
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:181:13
|
2021-09-08 14:31:47 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() };
|
2021-12-06 11:33:31 +00:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)`
|
2021-09-08 14:31:47 +00:00
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:185:13
|
2021-09-08 14:31:47 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(x) = Some(0) {
|
|
|
|
| _____________^
|
|
|
|
LL | | let s = s;
|
|
|
|
LL | | s.len() + x
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 1
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
|
|
|
LL ~ let _ = Some(0).map_or(1, |x| {
|
|
|
|
LL + let s = s;
|
|
|
|
LL + s.len() + x
|
|
|
|
LL ~ });
|
|
|
|
|
|
|
|
|
|
2022-08-31 13:24:45 +00:00
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:224:13
|
2022-08-31 13:24:45 +00:00
|
|
|
|
|
|
|
|
LL | let _ = match s {
|
|
|
|
| _____________^
|
|
|
|
LL | | Some(string) => string.len(),
|
|
|
|
LL | | None => 1,
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: try: `s.map_or(1, |string| string.len())`
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:228:13
|
2022-08-31 13:24:45 +00:00
|
|
|
|
|
|
|
|
LL | let _ = match Some(10) {
|
|
|
|
| _____________^
|
|
|
|
LL | | Some(a) => a + 1,
|
|
|
|
LL | | None => 5,
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: try: `Some(10).map_or(5, |a| a + 1)`
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:234:13
|
2022-08-31 13:24:45 +00:00
|
|
|
|
|
|
|
|
LL | let _ = match res {
|
|
|
|
| _____________^
|
|
|
|
LL | | Ok(a) => a + 1,
|
|
|
|
LL | | _ => 1,
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: try: `res.map_or(1, |a| a + 1)`
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:238:13
|
2022-08-31 13:24:45 +00:00
|
|
|
|
|
|
|
|
LL | let _ = match res {
|
|
|
|
| _____________^
|
|
|
|
LL | | Err(_) => 1,
|
|
|
|
LL | | Ok(a) => a + 1,
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: try: `res.map_or(1, |a| a + 1)`
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:242:13
|
2022-08-31 13:24:45 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if let Ok(a) = res { a + 1 } else { 5 };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)`
|
|
|
|
|
2023-07-02 12:35:19 +00:00
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:259:17
|
2023-07-02 12:35:19 +00:00
|
|
|
|
|
2023-11-29 18:22:28 +00:00
|
|
|
LL | let _ = match initial {
|
|
|
|
| _________________^
|
2023-07-02 12:35:19 +00:00
|
|
|
LL | | Some(value) => do_something(value),
|
2023-11-29 18:22:28 +00:00
|
|
|
LL | | None => 42,
|
|
|
|
LL | | };
|
|
|
|
| |_________^ help: try: `initial.as_ref().map_or(42, |value| do_something(value))`
|
2023-07-02 12:35:19 +00:00
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:266:17
|
2023-07-02 12:35:19 +00:00
|
|
|
|
|
2023-11-29 18:22:28 +00:00
|
|
|
LL | let _ = match initial {
|
|
|
|
| _________________^
|
2023-07-02 12:35:19 +00:00
|
|
|
LL | | Some(value) => do_something2(value),
|
2023-11-29 18:22:28 +00:00
|
|
|
LL | | None => 42,
|
|
|
|
LL | | };
|
|
|
|
| |_________^ help: try: `initial.as_mut().map_or(42, |value| do_something2(value))`
|
2023-07-02 12:35:19 +00:00
|
|
|
|
2023-09-04 08:15:45 +00:00
|
|
|
error: use Option::map_or_else instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:289:24
|
2023-09-04 08:15:45 +00:00
|
|
|
|
|
|
|
|
LL | let mut _hashmap = if let Some(hm) = &opt {
|
|
|
|
| ________________________^
|
|
|
|
LL | | hm.clone()
|
|
|
|
LL | | } else {
|
|
|
|
LL | | HashMap::new()
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: try: `opt.as_ref().map_or_else(HashMap::new, |hm| hm.clone())`
|
|
|
|
|
|
|
|
error: use Option::map_or_else instead of an if let/else
|
2023-11-29 18:22:28 +00:00
|
|
|
--> $DIR/option_if_let_else.rs:295:19
|
2023-09-04 08:15:45 +00:00
|
|
|
|
|
|
|
|
LL | let mut _hm = if let Some(hm) = &opt { hm.clone() } else { new_map!() };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.as_ref().map_or_else(|| new_map!(), |hm| hm.clone())`
|
|
|
|
|
|
|
|
error: aborting due to 25 previous errors
|
2020-07-14 12:59:59 +00:00
|
|
|
|