From d2890b773b29aebff66a9e25abf498f5131382eb 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 +++ Cargo.lock | 5 +++-- Cargo.toml | 2 +- README.md | 11 +++++++++-- src/lib.rs | 6 +++--- 5 files changed, 19 insertions(+), 8 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/Cargo.lock b/Cargo.lock index db6ec9f..cf53358 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "dbg_hex" -version = "0.1.1" - +version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index f1b72f3..8229ec2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dbg_hex" -version = "0.1.1" +version = "0.2.0" authors = ["wcampbell"] edition = "2018" repository = "https://github.com/wcampbell0x2a/dbg_hex" 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 } }