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 <jlusby@yaah.dev>
This commit is contained in:
DaniPopes 2024-04-25 23:52:12 +02:00 committed by GitHub
parent 586e359220
commit 1369e09fb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 {