From ea57dc3bc9253b8db8e0815bac344f2cf981894b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 27 Mar 2021 14:03:07 +0000 Subject: [PATCH] Use `matches` macro --- src/db/models/organization.rs | 20 ++++---------------- src/main.rs | 9 +++------ 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/db/models/organization.rs b/src/db/models/organization.rs index 2e93426d..50d46064 100644 --- a/src/db/models/organization.rs +++ b/src/db/models/organization.rs @@ -90,17 +90,11 @@ impl PartialOrd for UserOrgType { } fn gt(&self, other: &i32) -> bool { - match self.partial_cmp(other) { - Some(Ordering::Less) | Some(Ordering::Equal) => false, - _ => true, - } + !matches!(self.partial_cmp(other), Some(Ordering::Less) | Some(Ordering::Equal)) } fn ge(&self, other: &i32) -> bool { - match self.partial_cmp(other) { - Some(Ordering::Less) => false, - _ => true, - } + !matches!(self.partial_cmp(other), Some(Ordering::Less)) } } @@ -119,17 +113,11 @@ impl PartialOrd for i32 { } fn lt(&self, other: &UserOrgType) -> bool { - match self.partial_cmp(other) { - Some(Ordering::Less) | None => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Ordering::Less) | None) } fn le(&self, other: &UserOrgType) -> bool { - match self.partial_cmp(other) { - Some(Ordering::Less) | Some(Ordering::Equal) | None => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Ordering::Less) | Some(Ordering::Equal) | None) } } diff --git a/src/main.rs b/src/main.rs index 15b18b3c..dd397d17 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,10 +48,7 @@ fn main() { let level = LF::from_str(&CONFIG.log_level()).expect("Valid log level"); init_logging(level).ok(); - let extra_debug = match level { - LF::Trace | LF::Debug => true, - _ => false, - }; + let extra_debug = matches!(level, LF::Trace | LF::Debug); check_data_folder(); check_rsa_keys(); @@ -64,10 +61,10 @@ fn main() { const HELP: &str = "\ A Bitwarden API server written in Rust - + USAGE: bitwarden_rs - + FLAGS: -h, --help Prints help information -v, --version Prints the app version