]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/conf: collapse match pattern into if
authorJason Ish <jason.ish@oisf.net>
Tue, 6 Aug 2024 16:43:19 +0000 (10:43 -0600)
committerVictor Julien <victor@inliniac.net>
Wed, 7 Aug 2024 06:31:26 +0000 (08:31 +0200)
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

rust/src/conf.rs

index 50acf6cae895852ad2cc9203542d734a0bb0221b..0d28f4d8b494b1e0c13a888c60f8894cc3fa5c68 100644 (file)
@@ -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;