Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit 3a944ac

Browse files
bors[bot]nickray
andauthored
Merge #43
43: Actually use heprintln, and unwrap it r=adamgreig a=nickray I'm sorry, it's me again... - std::dbg panics on failure, given `dbg!` is advertised as "quick n' dirty" I think this behaviour makes sense here too (no need to type `.unwrap()` everywhere, no unused Result warnings) - also to be more analogous, actually use `heprintln` (as already advertised in documentation) - I went ahead and added the nod to 2018 edition missing last time Co-authored-by: Nicolas Stalder <n@stalder.io>
2 parents a98bb7c + d06a343 commit 3a944ac

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
77

88
- Adds a feature to work around JLink quirks
99
- Adds a dbg! macro using heprintln
10+
- Now Rust 2018 edition
1011

1112
## [v0.3.4] - 2019-04-22
1213

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@
129129
//! `dbg!` returns a given expression and prints it using `heprintln!` including context
130130
//! for quick and dirty debugging.
131131
//!
132+
//! Panics if `heprintln!` returns an error.
133+
//!
132134
//! Example:
133135
//!
134136
//! ```

src/macros.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,20 @@ macro_rules! heprintln {
8888

8989
/// Macro that prints and returns the value of a given expression
9090
/// for quick and dirty debugging. Works exactly like `dbg!` in
91-
/// the standard library, replacing `eprintln` with `heprintln`.
91+
/// the standard library, replacing `eprintln` with `heprintln`,
92+
/// which it unwraps.
9293
#[macro_export]
9394
macro_rules! dbg {
9495
() => {
95-
$crate::hprintln!("[{}:{}]", file!(), line!());
96+
$crate::heprintln!("[{}:{}]", file!(), line!()).unwrap();
9697
};
9798
($val:expr) => {
9899
// Use of `match` here is intentional because it affects the lifetimes
99100
// of temporaries - https://stackoverflow.com/a/48732525/1063961
100101
match $val {
101102
tmp => {
102-
$crate::hprintln!("[{}:{}] {} = {:#?}",
103-
file!(), line!(), stringify!($val), &tmp);
103+
$crate::heprintln!("[{}:{}] {} = {:#?}",
104+
file!(), line!(), stringify!($val), &tmp).unwrap();
104105
tmp
105106
}
106107
}

0 commit comments

Comments
 (0)