Debuggability - Rust API Guidelines (original) (raw)
- About
- Checklist
- 1. Naming
- 2. Interoperability
- 3. Macros
- 4. Documentation
- 5. Predictability
- 6. Flexibility
- 7. Type safety
- 8. Dependability
- 9. Debuggability
- 10. Future proofing
- 11. Necessities
- External links
Rust API Guidelines
Debuggability
All public types implement Debug (C-DEBUG)
If there are exceptions, they are rare.
Debug representation is never empty (C-DEBUG-NONEMPTY)
Even for conceptually empty values, the Debug
representation should never be empty.
#![allow(unused)]
fn main() {
let empty_str = "";
assert_eq!(format!("{:?}", empty_str), "\"\"");
let empty_vec = Vec::<bool>::new();
assert_eq!(format!("{:?}", empty_vec), "[]");
}