2021-03-06 17:08:46 +00:00
|
|
|
error: this could be simplified with `bool::then`
|
2021-03-08 13:52:03 +00:00
|
|
|
--> $DIR/if_then_some_else_none.rs:6:13
|
2021-03-06 17:08:46 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if foo() {
|
|
|
|
| _____________^
|
|
|
|
LL | | println!("true!");
|
|
|
|
LL | | Some("foo")
|
|
|
|
LL | | } else {
|
|
|
|
LL | | None
|
|
|
|
LL | | };
|
2021-03-08 14:19:57 +00:00
|
|
|
| |_____^
|
2021-03-06 17:08:46 +00:00
|
|
|
|
|
|
|
|
= note: `-D clippy::if-then-some-else-none` implied by `-D warnings`
|
2021-03-08 14:19:57 +00:00
|
|
|
= help: consider using `bool::then` like: `foo().then(|| { /* snippet */ "foo" })`
|
2021-03-06 17:08:46 +00:00
|
|
|
|
2021-03-08 13:52:03 +00:00
|
|
|
error: this could be simplified with `bool::then`
|
2021-03-12 11:46:46 +00:00
|
|
|
--> $DIR/if_then_some_else_none.rs:14:13
|
|
|
|
|
|
|
|
|
LL | let _ = if matches!(true, true) {
|
|
|
|
| _____________^
|
|
|
|
LL | | println!("true!");
|
|
|
|
LL | | Some(matches!(true, false))
|
|
|
|
LL | | } else {
|
|
|
|
LL | | None
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= help: consider using `bool::then` like: `matches!(true, true).then(|| { /* snippet */ matches!(true, false) })`
|
|
|
|
|
|
|
|
error: this could be simplified with `bool::then`
|
|
|
|
--> $DIR/if_then_some_else_none.rs:23:28
|
|
|
|
|
|
|
|
|
LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
= help: consider using `bool::then` like: `(o < 32).then(|| o)`
|
|
|
|
|
|
|
|
error: this could be simplified with `bool::then`
|
|
|
|
--> $DIR/if_then_some_else_none.rs:27:13
|
|
|
|
|
|
|
|
|
LL | let _ = if !x { Some(0) } else { None };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
= help: consider using `bool::then` like: `(!x).then(|| 0)`
|
|
|
|
|
|
|
|
error: this could be simplified with `bool::then`
|
|
|
|
--> $DIR/if_then_some_else_none.rs:82:13
|
2021-03-08 13:52:03 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if foo() {
|
|
|
|
| _____________^
|
|
|
|
LL | | println!("true!");
|
2021-03-08 14:19:57 +00:00
|
|
|
LL | | Some(150)
|
2021-03-08 13:52:03 +00:00
|
|
|
LL | | } else {
|
|
|
|
LL | | None
|
|
|
|
LL | | };
|
2021-03-08 14:19:57 +00:00
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= help: consider using `bool::then` like: `foo().then(|| { /* snippet */ 150 })`
|
2021-03-08 13:52:03 +00:00
|
|
|
|
2021-03-12 11:46:46 +00:00
|
|
|
error: aborting due to 5 previous errors
|
2021-03-06 17:08:46 +00:00
|
|
|
|