#custom #derive #debug #debugging #field #format

macro custom_debug_derive

Derive Debug with a custom format per field

12 releases (4 breaking)

0.5.0 Jun 12, 2020
0.4.0 Feb 1, 2020
0.3.0 Feb 1, 2020
0.2.0 Dec 12, 2019
0.1.4 Nov 27, 2018
Download history 2031/week @ 2021-09-26 2424/week @ 2021-10-03 2714/week @ 2021-10-10 2734/week @ 2021-10-17 2550/week @ 2021-10-24 2592/week @ 2021-10-31 2402/week @ 2021-11-07 2036/week @ 2021-11-14 2020/week @ 2021-11-21 2192/week @ 2021-11-28 2370/week @ 2021-12-05 2774/week @ 2021-12-12 1342/week @ 2021-12-19 555/week @ 2021-12-26 3250/week @ 2022-01-02 2336/week @ 2022-01-09

7,519 downloads per month
Used in 10 crates (3 directly)

Apache-2.0 OR MIT

15KB
361 lines

custom_debug

Derive Debug with a custom format per field.

Usage

Here is a showcase of all possible field attributes:

    use custom_debug::Debug;
    use std::fmt;

    #[deriveDebug)]
    struct Foo {
        #[debug(format = "{} things")]
        x: i32,
        #[debug(skip)]
        y: i32,
        #[debug(with = "hex_fmt")]
        z: i32,
    }

    fn hex_fmt<T: fmt::Debug>(n: &T, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "0x{:02X?}", n)
    }

The resulting debug output would look something like this:

Foo {
    x: 42 things,
    z: 0xAB
}

Dependencies

~370–790KB
~18K SLoC

^