Debug is a Rust formatting trait that produces developer-oriented representations of values. It is especially useful when an error must be displayed during a panic. section 2.5.6
Use Debug to support concise error handling:
- Derive Debug on an error enum so the compiler generates a printable representation. section 2.5.6
- Call unwrap() or expect() on a Result only when its error type implements Debug. section 2.5.6
- Use Debug output to reveal values such as enum variants, hidden escape codes, or data-structure internals. section 2.5.6 section 3.3
Making an error printable
Add #[derive(Debug)] to the error type, then unwrap() can report the failing value: thread 'main' panicked at 'called Result::unwrap() on an Err value: GotNegative'. section 2.5.6
#[derive(Debug)]
enum Error {
GotNegative,
}
See the minimal derive annotation that enables developer-oriented formatting for an error enum. section 2.5.6

