to_debug 0.1.0

An alternative to the ToString trait that uses the Debug trait
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented2 out of 3 items with examples
  • Size
  • Source code size: 3.72 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.05 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • joseph-gio/to_debug
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • JoJoJet

to_debug

This crate exports the [ToDebug] trait, which is an alternative to [ToString] that uses Debug instead of Display.

This can be useful for writing doctests, as it allows you to inspect the values of private fields:

mod private {
    #[derive(Debug)]
    pub struct Person { name: String, age: u16 }
    // constructor boilerplate...
}
let p = private::Person::new("Joseph", 20);
// assert_eq!(p.name, "Joseph"); // This would fail since `name` is private.
assert_eq!(p.to_debug(), r#"Person { name: "Joseph", age: 20 }"#);

License: MIT