diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-07-09 13:05:11 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-07-09 13:05:11 +0300 |
commit | 93f3d6e230f15b428f5be3a49b813cad093c0aa2 (patch) | |
tree | 2f2aa81847845655eeb3e549e4d1d3d4c2e9cab0 /melib | |
parent | 70e594959054b7955ddef0854e02fe588392e0db (diff) |
remove std::dbg uses
Diffstat (limited to 'melib')
-rw-r--r-- | melib/src/backends/maildir/backend.rs | 2 | ||||
-rw-r--r-- | melib/src/lib.rs | 34 |
2 files changed, 21 insertions, 15 deletions
diff --git a/melib/src/backends/maildir/backend.rs b/melib/src/backends/maildir/backend.rs index 9d1b45ea..08613661 100644 --- a/melib/src/backends/maildir/backend.rs +++ b/melib/src/backends/maildir/backend.rs @@ -478,7 +478,7 @@ impl MaildirType { continue 'entries; } if path.is_dir() { - let path_children = std::dbg!(recurse_folders(folders, &path)); + let path_children = recurse_folders(folders, &path); if let Ok(f) = MaildirFolder::new( path.to_str().unwrap().to_string(), path.file_name().unwrap().to_str().unwrap().to_string(), diff --git a/melib/src/lib.rs b/melib/src/lib.rs index 9edf2838..97b142dc 100644 --- a/melib/src/lib.rs +++ b/melib/src/lib.rs @@ -42,21 +42,27 @@ pub mod dbg { } }; ($val:expr) => { - { if cfg!(debug_assertions) { - eprint!( - "[{:?}] {}:{}_{}: ", - std::thread::current() - .name() - .map(std::string::ToString::to_string) - .unwrap_or_else(|| format!("{:?}", std::thread::current().id())), - file!(), - line!(), - column!() - ); - eprintln!("{} = {:?}", stringify!($val), $val); - } - $val + // Use of `match` here is intentional because it affects the lifetimes + // of temporaries - https://stackoverflow.com/a/48732525/1063961 + match $val { + tmp => { + eprint!( + "[{:?}] {}:{}_{}: ", + std::thread::current() + .name() + .map(std::string::ToString::to_string) + .unwrap_or_else(|| format!("{:?}", std::thread::current().id())), + file!(), + line!(), + column!() + ); + eprintln!("{} = {:?}", stringify!(tmp), tmp); + tmp + } + } + } else { + $val } }; ($fmt:literal, $($arg:tt)*) => { |