A derive macro like #[derive(Debug)] that doesn't require all fields to implement Debug.
Non-Debug fields display as <!Debug>. Field-level attributes control formatting.
See crate documentation for full usage and examples.
use dumpit::Dump;
struct Opaque;
#[derive(Dump)]
struct Config {
name: String,
_internal: Opaque,
#[dump(literal = "[-- redacted --]")]
password: String,
#[dump(truncate = 10)]
long_text: String,
#[dump(take = 5)]
binary: Vec<u8>,
}
let cfg = Config {
name: "app".to_string(),
_internal: Opaque,
password: "supersecret".to_string(),
long_text: "Lorem ipsum dolor sit amet".to_string(),
binary: (0..100).collect(),
};
println!("{:#?}", cfg);
// Outputs:
// r#"Config {
// name: "app",
// _internal: <!Debug>,
// password: "[-- redacted --]",
// long_text: "Lorem ipsu...",
// binary(5/100): [0, 1, 2, 3, 4],
// }"#
)Licensed under either of
at your option.