Small library to show manually-maintained context on panic

I want to present my very small library aimed to easy panic debugging: panic-context.

This library allows to print manually-maintained messages on panic.

When your program panics, it prints backtrace. However, if panic occurs inside loop, it is not clear which iteration was the cause. It is possible to use log, but printing slows down execution considerably and you get lots of entries, while only last ones are required.

Panic context lets you set value which is remembered, but not printed anywhere until panic occurs. It is also automatically forgotten at the end of scope.


for item in items {
    panic_context!("item: {}", item);

If panic occurs during item processing, then panic context will be printed:

Panic context:
item: cucumber
thread 'main' panicked at '...', src/libcore/str/
note: Run with `RUST_BACKTRACE=1` for a backtrace.