How to modify the output of dbg! macro

The default output of dbg! macro looks like this:

[src/main.rs:12] &slice = [
    1,
    3,
    0,
    2,
]

I want it to look like this:

[src/main.rs:12] &slice = [ 1, 3, 0, 2, ]

How to do that?

There's intentionally no customization of the dbg! macro. If you want a particular output, then you can use eprintln! directly.

but it doesn't show this [src/main.rs:12]. I also want from file, line and column the eprintln!() call is originated. So, that vscode treats it file location. And I can click it to go to that location

There are line, column, and file macros.

1 Like

Here's the current dbg! implementation if you want to make your own custom version. I believe you just want to delete the # on line 299.

(How to find: Searched for "Rust dbg", clicked top result to the docs, clicked [src] link on the right.)

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.