Skip to content

Commit

Permalink
rust: add macro to return val if unwrap fails
Browse files Browse the repository at this point in the history
  • Loading branch information
inashivb committed Jan 9, 2025
1 parent 107b9c2 commit 55efbb8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions rust/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ pub mod nom7 {
}
}

#[macro_export]
macro_rules!unwrap_or_return {
($e:expr, $r:expr) => {
match $e {
Ok(x) => x,
Err(_) => return $r,
}
}
}

#[cfg(not(feature = "debug-validate"))]
#[macro_export]
macro_rules! debug_validate_bug_on (
Expand Down

0 comments on commit 55efbb8

Please sign in to comment.