compact-debug

Crates.iocompact-debug
lib.rscompact-debug
version
sourcesrc
created_at2023-11-15 21:38:25.826512+00
updated_at2025-02-13 19:12:46.953122+00
descriptionMonkey-patches Rust's fmt system to make pretty-printing more compact
homepage
repositoryhttps://github.com/Kyuuhachi/Compact-Debug
max_upload_size
id1036866
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(Kyuuhachi)

documentation

README

Compact-Debug

{:#?} formatting, and the dbg!() macro, sound nice on paper. But once you try using them...

Goto(
    Address(
        30016,
    ),
),
Label(
    Address(
        29990,
    ),
),
Expr(
    Expr(
        Expr(
            [
                Var(
                    0,
                ),
                Const(
                    0,
                ),
                Op(
                    Ne,
                ),
            ],
        ),
    ),
    Address(
        30016,
    ),
),

Your dreams of nice and readable output are shattered by a chunk of output more porous than cotton candy, with approximately two tokens of content on each line. Screenful upon screenful of vacuous output for even a moderately complex type. Upset, you reluctantly replace your derived Debug implementation with a manual one that eschews DebugTuple in favor of write_str. However, this results in a catastrophic amount of boilerplate code, and doesn't affect types outside of your control, like the ubiquitous Option.

That's where this crate comes in. It monkey-patches the pretty-printing machinery so that DebugTuple is printed on a single line regardless of # flag. The above snippet is printed as:

Goto(Address(30016)),
Label(Address(29990)),
Expr(Expr(Expr([
    Var(0),
    Const(0),
    Op(Ne),
])), Address(30016)),

This crate currently only supports x86_64 architecture, and requires nightly.

Commit count: 5

cargo fmt