liveBook · Manning

Debug

Debug is a Rust standard-library trait for formatting values in programmer-oriented diagnostic representations.

How 2 Manning books explain it

Refactoring to Rust

The Debug trait is a Rust formatting trait for producing developer-oriented representations of values.

How it is used
Supports developer-oriented error output when Result values are unwrapped or expected to panic.
How deep it goes
Defines developer representation and demonstrates enum derivation, but defers deeper trait details.
Examples
Uses a FizzBuzz Error enum with GotNegative, #[derive(Debug)], unwrap(), expect(), and panic output.
What you can do after
Apply it via #[derive(Debug)] so Rust errors can be printed by unwrap() and expect().

Read how Refactoring to Rust explains Debug →

Learn Rust in a Month of Lunches

Debug is the Rust trait for producing programmer-oriented representations of values.

How it is used
Uses programmer-oriented output to inspect values when Display formatting is unavailable or insufficient.
How deep it goes
Explains format choices, compiler guidance, pretty output, and derive(Debug), but defers manual fmt implementation.
Examples
Uses the unit value (), compiler error E0277, and a User structure to contrast ordinary and pretty Debug output.
What you can do after
Apply Debug via println! using {:?}, {:#?}, and #[derive(Debug)] to inspect values.

Read how Learn Rust in a Month of Lunches explains Debug →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.