fix: compilation of the panic hook only on release

This commit is contained in:
Artemy 2022-08-15 17:23:28 +03:00
parent 1a693e38dd
commit 89f9b31c2b
2 changed files with 12 additions and 10 deletions

View file

@ -290,9 +290,10 @@
},
},
"fn sum(first, second){ return first+second};",
"Run function `sum`",
["fn sum(first, second){ return first+second}; sum(2,2) = ", { sum: [2, 2] }],
["sum(2, 2) = ", { sum: [2, 2] }],
"\nInput a var",
{

View file

@ -15,15 +15,16 @@ mod interpreter;
use interpreter::Interpreter;
fn main() {
// std::panic::set_hook(Box::new(|info| {
// eprint!(
// "{msg}",
// msg = match info.payload().downcast_ref::<String>() {
// None => "Program panicked without a message!",
// Some(x) => x,
// }
// );
// }));
#[cfg(not(debug_assertions))]
std::panic::set_hook(Box::new(|info| {
eprint!(
"{msg}",
msg = match info.payload().downcast_ref::<String>() {
None => "Program panicked without a message!",
Some(x) => x,
}
);
}));
let start = Instant::now();
let args = Args::parse();