Expand description
This crate provides macros that look just like panic!()
but instead of panicking, they cause
linking error if their calls are not optimized-out. This can be used to ensure the compiler
optimizes away some code.
§Example
#[macro_use]
extern crate dont_panic;
fn main() {
/*
let x = 6 * 9;
if x == 42 {
dont_panic!("6 * 9 == 42");
}
*/
let x = false;
if x {
dont_panic!("42");
}
}
Compile with --release
or --features=panic
Macros§
- dont_
panic - This macro doesn’t panic. Instead it tries to call non-existing function. If the compiler can prove it can’t be called an optimizes it away, the code will compile just fine. Else you get linking error.
- dp_
assert - Like asser but calls
dont_panic!()
instead ofpanic!()
Functions§
- rust_
panic_ ⚠called_ where_ shouldnt - This function doesn’t actually exist. It ensures linking error if it isn’t optimized-out.