Closed
Description
Hi!
I'm getting a false positive with the single_match_else
lint in an async
function declaration. I'm not 100% sure where this is happening, since the function has some Rocket procedural attributes in it.
First things first, cargo clippy -V
:
clippy 0.0.212 (69f99e7 2019-12-14)
The code that is causing the issue is the following:
#[get("/endpoint/?<meta>")]
async fn get_sth(
meta: Option<bool>,
) -> &'static str {
if meta == Some(true) {
"meta is true!"
} else {
"meta is false :("
}
}
I get this error:
warning: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> src/lib.rs:176:5
|
176 | meta: Option<bool>,
| ^^^^^^^^^^^^^^^^^^ help: try this: `if let meta: Option<bool> = meta: Option<bool> { meta: Option<bool> } else meta: Option<bool>`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
But this is a function header, so I cannot implement the proposed solution.