Debuggability - Rust API Guidelines (original) (raw)

  1. About
  2. Checklist
  3. 1. Naming
  4. 2. Interoperability
  5. 3. Macros
  6. 4. Documentation
  7. 5. Predictability
  8. 6. Flexibility
  9. 7. Type safety
  10. 8. Dependability
  11. 9. Debuggability
  12. 10. Future proofing
  13. 11. Necessities
  14. 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), "[]");
}