to_debug

Crates.ioto_debug
lib.rsto_debug
version0.1.0
sourcesrc
created_at2021-08-26 16:52:39.438656
updated_at2021-08-26 16:52:39.438656
descriptionAn alternative to the ToString trait that uses the Debug trait
homepage
repositoryhttps://github.com/JoJoJet/to_debug
max_upload_size
id442652
size4,099
Joseph (JoJoJet)

documentation

README

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

Commit count: 2

cargo fmt