From 1369e09fb2c4b7d3d33e63e083931cdea6766f48 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 25 Apr 2024 23:52:12 +0200 Subject: [PATCH] Don't evaluate 1-argument `ensure!` condition twice (#166) `ensure!($cond:expr)` currently expands to two nested `if !$cond {}`. Co-authored-by: Jane Losare-Lusby --- eyre/src/macros.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/eyre/src/macros.rs b/eyre/src/macros.rs index 032f82a..054a619 100644 --- a/eyre/src/macros.rs +++ b/eyre/src/macros.rs @@ -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 {