Provides wrapper structs with default Debug
impls.
This allows you to use the default implementation of Debug
for large structs while enabling you
to:
- avoid using Debug
impls that traverse deeply nested or overly large structures,
- avoid using a Debug
impl that leaks info that should not be logged.
This can improve:
- readability (logs can focus on the information you care about),
- debuggability & security (logs can be more complete without accidentally leaking private
info),
- and performance (complex data structures don't need to be traversed for debugging unless intentionally requested via Deref
).
Example usage: Hiding a user's password from logs. ```rust use no_debug::{NoDebug, WithTypeInfo, Ellipses};
struct UserInfo {
username: String,
password: NoDebug
let user = UserInfo { username: "Cypher1".tostring(), password: "hunter2".tostring().into(), posts: vec![ "long post 1...".tostring(), "long post 2...".tostring(), "long post 3...".to_string(), ].into() };
// The password is hidden by default
asserteq!(
format!("{:#?}", user),
r#"UserInfo {
username: "Cypher1",
password:
// The debug output is based on the Msg type. assert_eq!(format!("{:?}", user.posts), r#"..."#);
// Output can be changed easily with a type conversion
let postwithtype: NoDebug