Skip to content

Commit

Permalink
Merge pull request #170 from dtolnay/ensure
Browse files Browse the repository at this point in the history
Bypass anyhow_kind-based dispatch for ensure! with default msg
  • Loading branch information
dtolnay committed Oct 10, 2021
2 parents f94f720 + c904c82 commit 74fd4a2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/macros.rs
Expand Up @@ -114,10 +114,11 @@ macro_rules! bail {
#[macro_export]
macro_rules! ensure {
($cond:expr $(,)?) => {
$crate::ensure!(
$cond,
$crate::private::concat!("Condition failed: `", $crate::private::stringify!($cond), "`"),
)
if !$cond {
return $crate::private::Err($crate::private::new_adhoc(
$crate::private::concat!("Condition failed: `", $crate::private::stringify!($cond), "`")
));
}
};
($cond:expr, $msg:literal $(,)?) => {
if !$cond {
Expand Down

0 comments on commit 74fd4a2

Please sign in to comment.