diff --git a/examples/basic/src/main.rs b/examples/basic/src/main.rs index 39319d9..9b8ff2e 100644 --- a/examples/basic/src/main.rs +++ b/examples/basic/src/main.rs @@ -15,11 +15,16 @@ fn main() { for i in 0..5 { ensure!(false); ensure!(false, "ensure messages can be logged during development"); + ensure!(false, "ensure will only break once per false result"); ensure!(i % 2 == 0, "ensure messages can be formatted {}", i,); - ensure_always!(i % 2 == 0); + + ensure_always!(false); + ensure_always!(false, "ensure_always will happen multiple times"); + ensure_always!(false, "ensure_always messages can be formatted {}", i); fail!("fail! will happen only once"); - fail!("fail! can also format output - i was: {}", i); + fail!("fail! can also format output {}", i); + fail_always!("fail_always! will happen multiple times"); try_some_option(None); diff --git a/src/lib.rs b/src/lib.rs index 45f634a..f432843 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -145,10 +145,17 @@ macro_rules! ensure { #[cfg(all(debug_assertions, feature = "enable"))] macro_rules! ensure { ($expression: expr) => { - $crate::_internal::_once!($crate::ensure_always!($expression)) + if !$expression { + $crate::_internal::_once!($crate::breakpoint!()); + } }; ($expression: expr, $($argument: tt),+ $(,)?) => { - $crate::_internal::_once!($crate::ensure_always!($expression, $($argument),+)) + if !$expression { + $crate::_internal::_once!({ + $crate::_internal::_error!($($argument),+); + $crate::breakpoint!(); + }); + } }; }