dont_panic 0.1.0

panic!()-like macro that causes linking error instead of panicking. May be used to statically ensure some code won't panic.
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented0 out of 0 items with examples
  • Size
  • Source code size: 4.13 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 587.47 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • Kixunil/dont_panic
    64 5 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Kixunil

Don't panic!()

Ensure that code can't panic at compile time.

Example

This code will compile and (not) run just fine:

let should_panic = false;
if should_panic {
    dont_panic!("This will never execute.");
}

However, this code will cause linking error:

let should_panic = true;
if should_panic {
    dont_panic!("This will never execute.");
}

Caveats

  • This works only when appropriate opt_level is specified - it may require release build.
  • The error message is weird link error. You don't get line number, etc.
  • There may be situations in which you know that the code is unreachable but compiler can't prove it.