Skip to content
Myr

Bypass anyhow_kind-based dispatch for ensure! with default msg

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent f94f720 · Browse files · 1 file+5 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−4 removed

  • other:+5 added−4 removed

1 file+5 added−4 removed

modified:src/macros.rs+5 added-4 removed
112 unmodified lines
113/// ```114#[macro_export]115macro_rules! ensure {116 ($cond:expr $(,)?) => {117 $crate::ensure!(118 $cond,119 $crate::private::concat!("Condition failed: `", $crate::private::stringify!($cond), "`"),120 )117 if !$cond {118 return $crate::private::Err($crate::private::new_adhoc(119 $crate::private::concat!("Condition failed: `", $crate::private::stringify!($cond), "`")120 ));121 }122 };123 ($cond:expr, $msg:literal $(,)?) => {124 if !$cond {125 return $crate::private::Err($crate::anyhow!($msg));
59 unmodified lines