From: Jason Ish Date: Tue, 6 Aug 2024 16:43:19 +0000 (-0600) Subject: rust/conf: collapse match pattern into if X-Git-Tag: suricata-7.0.7~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ce35f581ac07b37537093ebdd0f781dbad2a59a;p=thirdparty%2Fsuricata.git rust/conf: collapse match pattern into if Fixes clippy lint for collapsible_match. error: this `match` can be collapsed into the outer `if let` --> src/conf.rs:85:9 | 85 | / match val { 86 | | "1" | "yes" | "true" | "on" => { 87 | | return true; 88 | | }, 89 | | _ => {}, 90 | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern --> src/conf.rs:84:17 | 84 | if let Some(val) = conf_get(key) { | ^^^ replace this binding 85 | match val { 86 | "1" | "yes" | "true" | "on" => { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ with this pattern = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match --- diff --git a/rust/src/conf.rs b/rust/src/conf.rs index 50acf6cae8..0d28f4d8b4 100644 --- a/rust/src/conf.rs +++ b/rust/src/conf.rs @@ -81,13 +81,8 @@ pub fn conf_get(key: &str) -> Option<&str> { // Return the value of key as a boolean. A value that is not set is // the same as having it set to false. pub fn conf_get_bool(key: &str) -> bool { - if let Some(val) = conf_get(key) { - match val { - "1" | "yes" | "true" | "on" => { - return true; - }, - _ => {}, - } + if let Some("1" | "yes" | "true" | "on") = conf_get(key) { + return true; } return false;