From: Shivani Bhardwaj Date: Thu, 9 Jan 2025 06:46:09 +0000 (+0530) Subject: rust: add macro to return val if unwrap fails X-Git-Tag: suricata-8.0.0-beta1~434 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ce8b15ca8d6eb5276832dc39c65187fe0ffad25;p=thirdparty%2Fsuricata.git rust: add macro to return val if unwrap fails --- diff --git a/rust/src/debug.rs b/rust/src/debug.rs index caeecff93a..16b128390f 100644 --- a/rust/src/debug.rs +++ b/rust/src/debug.rs @@ -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, + } + }; +);