liveBook · Manning

Debug

Debug is a Rust standard-library formatting trait for producing programmer-oriented representations of values.

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 →

Also covered in

What to know first

Related concepts

Questions about Debug

What is Debug?

Debug is a Rust standard-library formatting trait for producing programmer-oriented representations of values.

Which Manning books explain Debug?

Refactoring to Rust and Learn Rust in a Month of Lunches.

What should I know before learning Debug?

Manning books that teach Debug usually introduce Rust and string first.

What is the difference between Debug and Display?

Debug is a Rust standard-library formatting trait for producing programmer-oriented representations of values. Display is Rust’s standard formatting trait for producing a user-facing textual representation of a value.

What is Debug a kind of?

Debug is a kind of trait. A trait is a type-level construct that defines reusable behavior or members that types can implement or compose.

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.