]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: add macro to return val if unwrap fails
authorShivani Bhardwaj <shivani@oisf.net>
Thu, 9 Jan 2025 06:46:09 +0000 (12:16 +0530)
committerVictor Julien <victor@inliniac.net>
Sat, 15 Feb 2025 10:11:39 +0000 (11:11 +0100)
rust/src/debug.rs

index caeecff93a680544dff53990256661ac5b2e6f26..16b128390f4ca6341079222af02e527e56f39d74 100644 (file)
@@ -236,3 +236,13 @@ macro_rules! debug_validate_fail (
     }
   };
 );
+
+#[macro_export]
+macro_rules! unwrap_or_return (
+    ($e:expr, $r:expr) => {
+        match $e {
+            Ok(x) => x,
+            Err(_) => return $r,
+        }
+    };
+);