feat: use rust assertions in require! debug for line numbers
@@ -63,12 +63,18 @@ macro_rules! log {
#[macro_export]
macro_rules! require {
($cond:expr $(,)?) => {
- if !$cond {
- $crate::env::panic_str("require! assertion failed")
+ if cfg!(debug_assertions) {
+ assert!($cond)
+ } else if !$cond {
+ $crate::env::panic_str("require! assertion failed");
}
};
($cond:expr, $message:expr $(,)?) => {
- if !$cond {
+ if cfg!(debug_assertions) {
+ // Error message must be &str to match panic_str signature
+ let msg: &str = &$message;
+ assert!($cond, "{}", msg)
+ } else if !$cond {
$crate::env::panic_str(&$message)
}
};
