dumpit 0.1.0

Customizable `core::fmt::Debug` derive macro with field-level formatting options.
Documentation
  • Coverage
  • 16.67%
    3 out of 18 items documented1 out of 14 items with examples
  • Size
  • Source code size: 18.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.81 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 26s Average build duration of successful builds.
  • all releases: 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • b01o/dumpit
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • b01o

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.