Skip to content

Commit ba135d4

Browse files
committed
offer a ready-to-use dbg!
1 parent b3dae36 commit ba135d4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/stdio.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,21 @@ mod nativestdio {
8585
pub use self::nativestdio::Stdio;
8686
#[cfg(riot_module_stdio_uart)]
8787
pub use self::regular::Stdio;
88+
89+
// Copied and adapted from Rust 1.32.0
90+
#[macro_export]
91+
macro_rules! dbg {
92+
($val:expr) => {
93+
match $val {
94+
tmp => {
95+
use riot_wrappers::stdio::Stdio;
96+
use core::fmt::Write;
97+
writeln!(Stdio { }, "[{}:{}] {} = {:#?}",
98+
file!(), line!(), stringify!($val), &tmp);
99+
tmp
100+
}
101+
}
102+
}
103+
}
104+
105+
pub use dbg;

0 commit comments

Comments
 (0)