Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[macro_export]
- macro_rules! dbg {
- ($expr:expr) => (dbg!("{:#?}", $expr));
- ($fmt:expr, $expr:expr$(, $opt:expr)*) => {
- match $expr {
- expr => {
- eprintln!(concat!("[{}:{}] {} = ", $fmt), file!(), line!(), stringify!($expr), &expr$(, $opt)*);
- expr
- }
- }
- }
- }
- fn main() {
- let t = dbg!(2 + 1);
- // instead of this:
- let _: u64 = dbg!((1 << 63) | (t << 8));
- // this gives a nicer representation:
- let _: u64 = dbg!("0x{:x}", (1 << 63) | (t << 8));
- // this is also possible:
- let _: u64 = dbg!("0x{:x} with {}", (1 << 63) | (t << 8), t);
- }
Add Comment
Please, Sign In to add comment