Skip to content

Commit 251b162

Browse files
committed
Add column number to dbg output
See rust-lang/rust#114962
1 parent 110e61b commit 251b162

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
# dbg_hex
2-
display dbg result in hexadecimal `{:#x?}` format.
1+
dbg_hex
2+
===========================
3+
4+
[<img alt="github" src="https://img.shields.io/badge/github-wcampbell0x2a/dbg_hex-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/wcampbell0x2a/dbg_hex)
5+
[<img alt="crates.io" src="https://img.shields.io/crates/v/dbg_hex.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/dbg_hex)
6+
[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-dbg_hex-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs" height="20">](https://docs.rs/dbg_hex)
7+
[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/wcampbell0x2a/dbg_hex/main.yml?branch=master&style=for-the-badge" height="20">](https://github.com/wcampbell0x2a/dbg_hex/actions?query=branch%3Amaster)
8+
9+
Display dbg result in hexadecimal `{:#x?}` format.
310

411
# usage
512
Replace `dbg!()` with `dbg_hex!()`

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ macro_rules! dbg_hex {
2121
// `$val` expression could be a block (`{ .. }`), in which case the `eprintln!`
2222
// will be malformed.
2323
() => {
24-
eprintln!("[{}:{}]", file!(), line!());
24+
eprintln!("[{}:{}:{}]", file!(), line!(), column!());
2525
};
2626
($val:expr $(,)?) => {
2727
// Use of `match` here is intentional because it affects the lifetimes
2828
// of temporaries - https://stackoverflow.com/a/48732525/1063961
2929
match $val {
3030
tmp => {
31-
eprintln!("[{}:{}] {} = {:#x?}",
32-
file!(), line!(), stringify!($val), &tmp);
31+
eprintln!("[{}:{}:{}] {} = {:#x?}",
32+
file!(), line!(), column!(), stringify!($val), &tmp);
3333
tmp
3434
}
3535
}

0 commit comments

Comments
 (0)