test out better debugging

This commit is contained in:
nora 2022-04-23 17:03:17 +02:00
parent 6a8eb89381
commit 5f9ca90fd5
13 changed files with 422 additions and 145 deletions

View file

@ -1,9 +1,20 @@
/// Statically asserts that the size of the type is x bytes big (on 64-bit)
macro_rules! assert_size {
($name:ident == $size:expr) => {
($name:ident <= $size:expr) => {
#[cfg(target_pointer_width = "64")]
const _: [(); $size] = [(); ::std::mem::size_of::<$name>()];
};
}
pub(crate) use assert_size;
use std::fmt::Display;
#[cfg(feature = "_debug")]
pub fn dbg(prefix: impl Display, x: impl dbg_pls::DebugPls) {
eprintln!("{prefix}{}", dbg_pls::pretty(&x))
}
#[cfg(not(feature = "_debug"))]
pub fn dbg(prefix: impl Display, x: impl std::fmt::Debug) {
eprintln!("{prefix}{x:#?}");
}