Skip to content

Commit

Permalink
Bypass anyhow_kind-based dispatch for ensure! with default msg
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 10, 2021
1 parent f94f720 commit c904c82
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/macros.rs
Original file line number Diff line number Diff line change
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 c904c82

Please sign in to comment.