2020-03-05 12:35:05 -06:00
|
|
|
error: use Option::map_or instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:7:5
|
2020-03-05 12:35:05 -06: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`
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:17:12
|
2020-04-25 10:32:33 -05:00
|
|
|
|
|
|
|
|
LL | } else if let Some(x) = string {
|
|
|
|
| ____________^
|
|
|
|
LL | | Some((true, x))
|
|
|
|
LL | | } else {
|
|
|
|
LL | | Some((false, ""))
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: try: `{ string.map_or(Some((false, "")), |x| Some((true, x))) }`
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:25:13
|
2020-03-05 12:35:05 -06:00
|
|
|
|
|
2020-05-09 22:44:56 -05:00
|
|
|
LL | let _ = if let Some(s) = *string { s.len() } else { 0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())`
|
2020-05-09 22:20:57 -05:00
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:26:13
|
2020-05-09 22:20:57 -05:00
|
|
|
|
|
2020-05-09 22:44:56 -05:00
|
|
|
LL | let _ = if let Some(s) = &num { s } else { &0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
|
2020-05-09 22:20:57 -05:00
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:27:13
|
2020-05-09 22:20:57 -05:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(s) = &mut num {
|
|
|
|
| _____________^
|
|
|
|
LL | | *s += 1;
|
|
|
|
LL | | s
|
|
|
|
LL | | } else {
|
|
|
|
LL | | &mut 0
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
|
|
|
LL | let _ = num.as_mut().map_or(&mut 0, |s| {
|
|
|
|
LL | *s += 1;
|
|
|
|
LL | s
|
|
|
|
LL | });
|
|
|
|
|
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:33:13
|
2020-05-09 22:20:57 -05:00
|
|
|
|
|
2020-05-09 22:44:56 -05:00
|
|
|
LL | let _ = if let Some(ref s) = num { s } else { &0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
|
2020-05-09 22:20:57 -05:00
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:34:13
|
2020-05-09 22:20:57 -05:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(mut s) = num {
|
|
|
|
| _____________^
|
|
|
|
LL | | s += 1;
|
|
|
|
LL | | s
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 0
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
|
|
|
LL | let _ = num.map_or(0, |mut s| {
|
|
|
|
LL | s += 1;
|
|
|
|
LL | s
|
|
|
|
LL | });
|
|
|
|
|
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:40:13
|
2020-05-09 22:20:57 -05:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(ref mut s) = num {
|
|
|
|
| _____________^
|
|
|
|
LL | | *s += 1;
|
|
|
|
LL | | s
|
|
|
|
LL | | } else {
|
|
|
|
LL | | &mut 0
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
|
|
|
LL | let _ = num.as_mut().map_or(&mut 0, |s| {
|
|
|
|
LL | *s += 1;
|
|
|
|
LL | s
|
|
|
|
LL | });
|
|
|
|
|
|
2020-04-25 11:08:23 -05:00
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:49:5
|
2020-04-25 11:08:23 -05:00
|
|
|
|
|
2020-03-05 12:35:05 -06:00
|
|
|
LL | / if let Some(x) = arg {
|
|
|
|
LL | | let y = x * x;
|
|
|
|
LL | | y * y
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 13
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
|
|
|
LL | arg.map_or(13, |x| {
|
|
|
|
LL | let y = x * x;
|
|
|
|
LL | y * y
|
|
|
|
LL | })
|
|
|
|
|
|
|
|
|
|
|
|
|
error: use Option::map_or_else instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:62:13
|
2020-08-21 17:43:04 -05:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(x) = arg {
|
|
|
|
| _____________^
|
|
|
|
LL | | x
|
|
|
|
LL | | } else {
|
|
|
|
LL | | // map_or_else must be suggested
|
|
|
|
LL | | side_effect()
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: try: `arg.map_or_else(|| side_effect(), |x| x)`
|
|
|
|
|
|
|
|
error: use Option::map_or_else instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:71:13
|
2020-03-05 12:35:05 -06: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
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
error: use Option::map_or instead of an if let/else
|
2020-10-13 15:47:46 -05:00
|
|
|
--> $DIR/option_if_let_else.rs:100:13
|
2020-03-05 12:35:05 -06:00
|
|
|
|
|
|
|
|
LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
|
|
|
|
|
2020-08-21 17:43:04 -05:00
|
|
|
error: aborting due to 12 previous errors
|
2020-03-05 12:35:05 -06:00
|
|
|
|