Skip to main content

Dump

Derive Macro Dump 

Source
#[derive(Dump)]
{
    // Attributes available to this derive:
    #[dump]
}
Expand description

The main entry point for the #[derive(Dump)] macro.

supported attributes:

  • #[dump(skip)] — skip this field entirely
  • #[dump(skip_if = "expr")] — skip if the expression evaluates to true (expr can refer to self and field names)
  • #[dump(format = "fmt", arg1, arg2, ...)] — use a custom format string with optional arguments.
  • #[dump(literal = "value")] — ignore the field value and print the literal instead
  • #[dump(with = "path::to::func")] — use a custom function to format the field. The function should have signature fn(&T, &mut Formatter) -> fmt::Result where T is the field type.
  • #[dump(take = n)] — for iterable fields, only include the first n items and show the count as “name(n/total)”
  • #[dump(truncate = n)] — debug-format the field value, then truncate the output to n characters (adding “…” if truncated).