From ac41bb79d153d5c20768c368d95246da1230af8a Mon Sep 17 00:00:00 2001 From: wcampbell Date: Sat, 20 Jan 2024 13:02:13 -0500 Subject: [PATCH] Add column number to dbg output See https://github.com/rust-lang/rust/pull/114962 --- CHANGELOG.md | 3 +++ README.md | 11 +++++++++-- src/lib.rs | 6 +++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bae25b8..5c2c04c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.2.0] - 2024-01-20 +- Add column number to dbg output ([#4](https://github.com/wcampbell0x2a/dbg_hex/pull/4)) + ## [0.1.1] - 2020-08-08 - Fix `dbg_hex` not working with multiple inputs ([@Zenithsiz](https://github.com/zenithsiz)) ([#1](https://github.com/wcampbell0x2a/dbg_hex/pull/1)) diff --git a/README.md b/README.md index ddcfb08..1770c9e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,12 @@ -# dbg_hex -display dbg result in hexadecimal `{:#x?}` format. +dbg_hex +=========================== + +[github](https://github.com/wcampbell0x2a/dbg_hex) +[crates.io](https://crates.io/crates/dbg_hex) +[docs.rs](https://docs.rs/dbg_hex) +[build status](https://github.com/wcampbell0x2a/dbg_hex/actions?query=branch%3Amaster) + +Display dbg result in hexadecimal `{:#x?}` format. # usage Replace `dbg!()` with `dbg_hex!()` diff --git a/src/lib.rs b/src/lib.rs index 1f6bcd0..484e7ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,15 +21,15 @@ macro_rules! dbg_hex { // `$val` expression could be a block (`{ .. }`), in which case the `eprintln!` // will be malformed. () => { - eprintln!("[{}:{}]", file!(), line!()); + eprintln!("[{}:{}:{}]", file!(), line!(), column!()); }; ($val:expr $(,)?) => { // Use of `match` here is intentional because it affects the lifetimes // of temporaries - https://stackoverflow.com/a/48732525/1063961 match $val { tmp => { - eprintln!("[{}:{}] {} = {:#x?}", - file!(), line!(), stringify!($val), &tmp); + eprintln!("[{}:{}:{}] {} = {:#x?}", + file!(), line!(), column!(), stringify!($val), &tmp); tmp } }