Skip to content

Commit

Permalink
Add column number to dbg output
Browse files Browse the repository at this point in the history
  • Loading branch information
wcampbell0x2a committed Jan 20, 2024
1 parent 110e61b commit d2890b7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# dbg_hex
display dbg result in hexadecimal `{:#x?}` format.
dbg_hex
===========================

[<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)
[<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)
[<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)
[<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)

Display dbg result in hexadecimal `{:#x?}` format.

# usage
Replace `dbg!()` with `dbg_hex!()`
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit d2890b7

Please sign in to comment.