Implement Debug for Public Types
RUST-IMPLEMENT-DEBUG-FOR-PUBLIC-TYPES
Summary
Provide Debug for public types unless it would expose secrets or mislead callers. The trait is baseline support for tests, assertions, logs, and downstream diagnostics.
Rule
Implement Debug for public types unless that is unsafe or misleading.
Why
Debug is the baseline diagnostic trait for Rust values. Public types without Debug make tests,
logs, assertions, and downstream debugging harder unless the type contains sensitive data or cannot
be represented safely.
Helps
Helps downstream tests, logs, assertions, and diagnostics show useful values without bespoke formatting.
Limits
Avoid or customize Debug when it would expose secrets, huge data, unstable internals, or
misleading representations.
Agent Instruction
Implement `Debug` for public types unless that is unsafe or misleading; `Debug` is the baseline
diagnostic trait for Rust values.Mechanisms
Derive Debug for ordinary public types, write manual implementations for redaction or stable
summaries, and include Debug bounds only when the API truly needs them.