matches!(..)
instead 57 let db = scripty_db::get_db();
58
59 let premium_tier = scripty_premium::get_guild(ctx.guild_id().unwrap().get()).await;
60 let extra = if let Some(PremiumTierList::None) = premium_tier { 61 format_message!(resolved_language, "automod-setup-embed-complete-free-limit")
62 } else {
63 "".to_string()
let
bindings in the form of if-let
and while-let
expressions are unnecessary unless they contain a pattern capture.
Consider using the matches!
macro or testing equality ==
instead. Since the matches!
macro was introduced in 1.42, this issue is raised only if the msrv
flag in your .deepsource.toml
file is set accordingly.
fn main() {
if let Some(1) = foo() {}
if let Bar(_) = bar() {}
}
// or,
enum EnumABC { A(i32), B(u32), C(&'static str) }
fn bar() -> EnumABC { EnumABC::B(10u32) }
fn foo() {
let EnumABC::A(_) = bar() else { return None; }
}
fn main() {
if foo() == Some(1) {}
if matches!(bar(), Bar(_)) {}
}
// or,
enum EnumABC { A(i32), B(u32), C(&'static str) }
fn bar() -> EnumABC { EnumABC::B(10u32) }
fn foo() {
if !matches!(bar(), EnumABC::A(_)) { return None; }
}