Skip to content

Commit

Permalink
Don't evaluate 1-argument ensure! condition twice (#166)
Browse files Browse the repository at this point in the history
`ensure!($cond:expr)` currently expands to two nested `if !$cond {}`.

Co-authored-by: Jane Losare-Lusby <[email protected]>
  • Loading branch information
DaniPopes and yaahc authored Apr 25, 2024
1 parent 586e359 commit 1369e09
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions eyre/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ macro_rules! bail {
#[macro_export]
macro_rules! ensure {
($cond:expr $(,)?) => {
if !$cond {
$crate::ensure!($cond, concat!("Condition failed: `", stringify!($cond), "`"))
}
$crate::ensure!($cond, concat!("Condition failed: `", stringify!($cond), "`"))
};
($cond:expr, $msg:literal $(,)?) => {
if !$cond {
Expand Down

0 comments on commit 1369e09

Please sign in to comment.