reproducible-panic

Crates.ioreproducible-panic
lib.rsreproducible-panic
version0.1.2
created_at2026-01-19 18:02:21.293948+00
updated_at2026-01-19 19:01:02.179067+00
descriptionpanic hook with reproducible output
homepage
repositoryhttps://github.com/de-vri-es/reproducible-panic
max_upload_size
id2055037
size8,353
Maarten de Vries (de-vri-es)

documentation

https://docs.rs/reproducible-panic

README

reproducible-panic

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.

Example

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.

Commit count: 5

cargo fmt