Skip to content

b01o/dumpit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dumpit

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],
// }"#
)

License

Licensed under either of

at your option.

About

Customizable `core::fmt::Debug` derive macro with field-level formatting options.

Resources

Stars

Watchers

Forks

Contributors

Languages