mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 16:39:26 +00:00
61 lines
1.8 KiB
Text
61 lines
1.8 KiB
Text
error: this could be simplified with `bool::then`
|
|
--> $DIR/if_then_some_else_none.rs:5:13
|
|
|
|
|
LL | let _ = if foo() {
|
|
| _____________^
|
|
LL | | println!("true!");
|
|
LL | | Some("foo")
|
|
LL | | } else {
|
|
LL | | None
|
|
LL | | };
|
|
| |_____^
|
|
|
|
|
= help: consider using `bool::then` like: `foo().then(|| { /* snippet */ "foo" })`
|
|
= note: `-D clippy::if-then-some-else-none` implied by `-D warnings`
|
|
|
|
error: this could be simplified with `bool::then`
|
|
--> $DIR/if_then_some_else_none.rs:13: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_some`
|
|
--> $DIR/if_then_some_else_none.rs:22:28
|
|
|
|
|
LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: consider using `bool::then_some` like: `(o < 32).then_some(o)`
|
|
|
|
error: this could be simplified with `bool::then_some`
|
|
--> $DIR/if_then_some_else_none.rs:26:13
|
|
|
|
|
LL | let _ = if !x { Some(0) } else { None };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: consider using `bool::then_some` like: `(!x).then_some(0)`
|
|
|
|
error: this could be simplified with `bool::then`
|
|
--> $DIR/if_then_some_else_none.rs:81:13
|
|
|
|
|
LL | let _ = if foo() {
|
|
| _____________^
|
|
LL | | println!("true!");
|
|
LL | | Some(150)
|
|
LL | | } else {
|
|
LL | | None
|
|
LL | | };
|
|
| |_____^
|
|
|
|
|
= help: consider using `bool::then` like: `foo().then(|| { /* snippet */ 150 })`
|
|
|
|
error: aborting due to 5 previous errors
|
|
|