| Crates.io | reproducible-panic |
| lib.rs | reproducible-panic |
| version | 0.1.2 |
| created_at | 2026-01-19 18:02:21.293948+00 |
| updated_at | 2026-01-19 19:01:02.179067+00 |
| description | panic hook with reproducible output |
| homepage | |
| repository | https://github.com/de-vri-es/reproducible-panic |
| max_upload_size | |
| id | 2055037 |
| size | 8,353 |
A panic hook that mimics the default panic hook, but without printing non-reproducible information.
This is useful for snapshot tests where you compare the output of a program to verify it is still functioning correct. If the program panics, the default hook includes the ID of the panicking thread, which is different on every run.
Rather than trying to filter it out, you can have the program install this panic hook to prevent it from being printed in the first place.
fn main() {
reproducible_panic::install();
panic!("Oh no!");
}
Produces the following output:
thread 'main' panicked at examples/example.rs:3:5
Oh no!
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
In contrast, with the default panic hook the first line would look like this:
thread 'main' (12993) panicked at examples/example.rs:3:5:
Note the "12993" in the output. This number will be different every time you run the program, ruining your snapshot tests.