How to modify the output of dbg! macro

The default output of dbg! macro looks like this:

[src/] &slice = [

I want it to look like this:

[src/] &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/]. 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.)


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.