diff --git a/CHANGELOG.md b/CHANGELOG.md index 393a026..3abe082 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Adds a feature to work around JLink quirks - Adds a dbg! macro using heprintln +- Now Rust 2018 edition ## [v0.3.4] - 2019-04-22 diff --git a/src/lib.rs b/src/lib.rs index 580ed73..6c22926 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -129,6 +129,8 @@ //! `dbg!` returns a given expression and prints it using `heprintln!` including context //! for quick and dirty debugging. //! +//! Panics if `heprintln!` returns an error. +//! //! Example: //! //! ``` diff --git a/src/macros.rs b/src/macros.rs index 263d5fe..9aaceef 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -88,19 +88,20 @@ macro_rules! heprintln { /// Macro that prints and returns the value of a given expression /// for quick and dirty debugging. Works exactly like `dbg!` in -/// the standard library, replacing `eprintln` with `heprintln`. +/// the standard library, replacing `eprintln` with `heprintln`, +/// which it unwraps. #[macro_export] macro_rules! dbg { () => { - $crate::hprintln!("[{}:{}]", file!(), line!()); + $crate::heprintln!("[{}:{}]", file!(), line!()).unwrap(); }; ($val:expr) => { // Use of `match` here is intentional because it affects the lifetimes // of temporaries - https://stackoverflow.com/a/48732525/1063961 match $val { tmp => { - $crate::hprintln!("[{}:{}] {} = {:#?}", - file!(), line!(), stringify!($val), &tmp); + $crate::heprintln!("[{}:{}] {} = {:#?}", + file!(), line!(), stringify!($val), &tmp).unwrap(); tmp } }