Crates.io | unreachable_checked |
lib.rs | unreachable_checked |
version | 0.2.0 |
source | src |
created_at | 2023-04-01 21:57:47.33237 |
updated_at | 2023-04-01 22:01:34.951594 |
description | unreachable!()-like macro that causes linking error instead of panicking. May be used to statically ensure some code won't panic. |
homepage | https://github.com/DrSloth/unreachable_checked |
repository | https://github.com/DrSloth/unreachable_checked |
max_upload_size | |
id | 827642 |
size | 7,913 |
A fork of Kixunil/dont_panic that uses unreachable! instead of panic!
Ensures that code can't panic at compile time.
This code will compile and (not) run just fine:
let should_panic = false;
if should_panic {
unreachable_checked!("This will never execute.");
}
However, this code will cause a linking error:
let should_panic = true;
if should_panic {
unreachable_checked!("This will never execute.");
}
panic
cargo feature to panic instead